~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/last_insert.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
22
22
#include <drizzled/function/last_insert.h>
23
23
#include <drizzled/session.h>
24
24
 
25
 
namespace drizzled
26
 
{
27
 
 
28
25
int64_t Item_func_last_insert_id::val_int()
29
26
{
 
27
  Session *session= current_session;
30
28
  assert(fixed == 1);
31
29
  if (arg_count)
32
30
  {
33
31
    int64_t value= args[0]->val_int();
34
32
    null_value= args[0]->null_value;
35
33
    /*
36
 
      LAST_INSERT_ID(X) must affect the client's insert_id() as
 
34
      LAST_INSERT_ID(X) must affect the client's mysql_insert_id() as
37
35
      documented in the manual. We don't want to touch
38
36
      first_successful_insert_id_in_cur_stmt because it would make
39
37
      LAST_INSERT_ID(X) take precedence over an generated auto_increment
40
38
      value for this row.
41
39
    */
42
 
    getSession().arg_of_last_insert_id_function= true;
43
 
    getSession().first_successful_insert_id_in_prev_stmt= value;
44
 
 
 
40
    session->arg_of_last_insert_id_function= true;
 
41
    session->first_successful_insert_id_in_prev_stmt= value;
45
42
    return value;
46
43
  }
47
 
  return getSession().read_first_successful_insert_id_in_prev_stmt();
 
44
  return session->read_first_successful_insert_id_in_prev_stmt();
48
45
}
49
46
 
50
47
 
53
50
  return Item_int_func::fix_fields(session, ref);
54
51
}
55
52
 
56
 
} /* namespace drizzled */