~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/last_insert.cc

  • Committer: Djellel E. Difallah
  • Date: 2010-03-27 10:10:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1429.
  • Revision ID: ded@ubuntu-20100327101049-oo3arvatjoyku124
merge my_decimal and decimal

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>
 
20
#include "config.h"
21
21
 
22
22
#include <drizzled/function/last_insert.h>
23
23
#include <drizzled/session.h>
27
27
 
28
28
int64_t Item_func_last_insert_id::val_int()
29
29
{
 
30
  Session *session= current_session;
30
31
  assert(fixed == 1);
31
32
  if (arg_count)
32
33
  {
33
34
    int64_t value= args[0]->val_int();
34
35
    null_value= args[0]->null_value;
35
36
    /*
36
 
      LAST_INSERT_ID(X) must affect the client's insert_id() as
 
37
      LAST_INSERT_ID(X) must affect the client's mysql_insert_id() as
37
38
      documented in the manual. We don't want to touch
38
39
      first_successful_insert_id_in_cur_stmt because it would make
39
40
      LAST_INSERT_ID(X) take precedence over an generated auto_increment
40
41
      value for this row.
41
42
    */
42
 
    getSession().arg_of_last_insert_id_function= true;
43
 
    getSession().first_successful_insert_id_in_prev_stmt= value;
44
 
 
 
43
    session->arg_of_last_insert_id_function= true;
 
44
    session->first_successful_insert_id_in_prev_stmt= value;
45
45
    return value;
46
46
  }
47
 
  return getSession().read_first_successful_insert_id_in_prev_stmt();
 
47
  return session->read_first_successful_insert_id_in_prev_stmt();
48
48
}
49
49
 
50
50