~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/field.cc

  • Committer: Mark Atwood
  • Date: 2011-12-22 04:39:00 UTC
  • mfrom: (2472.1.2 drizzle-build)
  • Revision ID: me@mark.atwood.name-20111222043900-utca466m80z3gj61
mergeĀ lp:~brianaker/drizzle/null-safety-fix-libdrizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                                   size_t *size, size_t *total,
51
51
                                   drizzle_return_t *ret_ptr)
52
52
{
 
53
  drizzle_return_t unused_ret;
 
54
  if (ret_ptr == NULL)
 
55
  {
 
56
    ret_ptr= &unused_ret;
 
57
  }
 
58
 
 
59
  if (result == NULL)
 
60
  {
 
61
    *ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT;
 
62
    return drizzle_field_t();
 
63
  }
 
64
 
53
65
  if (drizzle_state_none(result->con))
54
66
  {
55
67
    if (result->field_current == result->column_count)
68
80
    *ret_ptr= DRIZZLE_RETURN_ROW_BREAK;
69
81
  }
70
82
 
71
 
  *offset= result->field_offset;
72
 
  *size= result->field_size;
73
 
  *total= result->field_total;
 
83
  if (offset)
 
84
  {
 
85
    *offset= result->field_offset;
 
86
  }
 
87
 
 
88
  if (size)
 
89
  {
 
90
    *size= result->field_size;
 
91
  }
 
92
 
 
93
  if (total)
 
94
  {
 
95
    *total= result->field_total;
 
96
  }
74
97
 
75
98
  return result->field;
76
99
}
81
104
  size_t offset= 0;
82
105
  size_t size= 0;
83
106
 
 
107
  drizzle_return_t unused_ret;
 
108
  if (ret_ptr == NULL)
 
109
  {
 
110
    ret_ptr= &unused_ret;
 
111
  }
 
112
 
 
113
  if (result == NULL)
 
114
  {
 
115
    *ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT;
 
116
    return drizzle_field_t();
 
117
  }
 
118
 
84
119
  drizzle_field_t field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
85
120
 
86
121
  if (*ret_ptr != DRIZZLE_RETURN_OK)
141
176
                                     const drizzle_field_t field, size_t size,
142
177
                                     size_t total)
143
178
{
 
179
  if (result == NULL)
 
180
  {
 
181
    return  DRIZZLE_RETURN_INVALID_ARGUMENT;
 
182
  }
 
183
 
144
184
  drizzle_return_t ret;
145
185
 
146
186
  if (drizzle_state_none(result->con))
180
220
 
181
221
drizzle_return_t drizzle_state_field_read(drizzle_con_st *con)
182
222
{
183
 
  drizzle_return_t ret;
184
 
 
 
223
  if (con == NULL)
 
224
  {
 
225
    return DRIZZLE_RETURN_INVALID_ARGUMENT;
 
226
  }
185
227
  drizzle_log_debug(con->drizzle, "drizzle_state_field_read");
186
228
 
187
229
  if (con->buffer_size == 0)
196
238
    con->result->field_offset= 0;
197
239
    con->result->field_size= 0;
198
240
 
 
241
    drizzle_return_t ret;
199
242
    con->result->field_total= (size_t)drizzle_unpack_length(con, &ret);
200
243
    if (ret == DRIZZLE_RETURN_NULL_SIZE)
201
244
    {
221
264
                      con->result->field_total);
222
265
 
223
266
    if ((size_t)(con->buffer_size) >= con->result->field_total)
 
267
    {
224
268
      con->result->field_size= con->result->field_total;
 
269
    }
225
270
    else
 
271
    {
226
272
      con->result->field_size= con->buffer_size;
 
273
    }
227
274
  }
228
275
  else
229
276
  {
234
281
                                con->result->field_offset);
235
282
    }
236
283
    else
 
284
    {
237
285
      con->result->field_size= con->buffer_size;
 
286
    }
238
287
  }
239
288
 
240
289
  /* This is a special case when a row is larger than the packet size. */
243
292
    con->result->field_size= con->packet_size;
244
293
 
245
294
    if (con->options & DRIZZLE_CON_RAW_PACKET)
 
295
    {
246
296
      con->result->options|= DRIZZLE_RESULT_ROW_BREAK;
 
297
    }
247
298
    else
248
299
    {
249
300
      drizzle_state_pop(con);
287
338
 
288
339
drizzle_return_t drizzle_state_field_write(drizzle_con_st *con)
289
340
{
 
341
  if (con == NULL)
 
342
  {
 
343
    return DRIZZLE_RETURN_INVALID_ARGUMENT;
 
344
  }
 
345
 
290
346
  uint8_t *start= con->buffer_ptr + con->buffer_size;
291
347
  uint8_t *ptr;
292
348
  size_t free_size;
387
443
      }
388
444
 
389
445
      if (result->field_size == free_size)
 
446
      {
390
447
        result->field= NULL;
 
448
      }
391
449
      else
392
450
      {
393
451
        result->field+= free_size;