~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/set_user_var.cc

Merge Revision revid:marko.makela@oracle.com-20100514133144-fe0l0b89tea4x4uu from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100514133144-fe0l0b89tea4x4uu

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Merge from mysql-5.1-innodb:

Post-merge fixes: Remove the MYSQL_VERSION_ID checks, because they only
apply to the InnoDB Plugin. Fix potential race condition accessing
trx->op_info and trx->detailed_error.
------------------------------------------------------------
revno: 3466
revision-id: marko.makela@oracle.com-20100514130815-ym7j7cfu88ro6km4
parent: marko.makela@oracle.com-20100514130228-n3n42nw7ht78k0wn
committer: Marko Mkel <marko.makela@oracle.com>
branch nick: mysql-5.1-innodb2
timestamp: Fri 2010-05-14 16:08:15 +0300
message:
  Make the InnoDB FOREIGN KEY parser understand multi-statements. (Bug #48024)
  Also make InnoDB thinks that /*/ only starts a comment. (Bug #53644).

  This fixes the bugs in the InnoDB Plugin.

  ha_innodb.h: Use trx_query_string() instead of trx_query() when
  available (MySQL 5.1.42 or later).

  innobase_get_stmt(): New function, to retrieve the currently running
  SQL statement.

  struct trx_struct: Remove mysql_query_str. Use innobase_get_stmt() instead.

  dict_strip_comments(): Add and observe the parameter sql_length. Treat
  /*/ as the start of a comment.

  dict_create_foreign_constraints(), row_table_add_foreign_constraints():
  Add the parameter sql_length.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <drizzled/server_includes.h>
21
 
#include CSTDINT_H
22
 
#include <drizzled/functions/set_user_var.h>
23
 
#include <drizzled/functions/get_variable.h>
24
 
#include <drizzled/functions/update_hash.h>
 
20
#include "config.h"
 
21
 
 
22
#include <drizzled/function/set_user_var.h>
25
23
#include <drizzled/field/num.h>
26
 
#include <drizzled/virtual_column_info.h>
27
24
#include <drizzled/session.h>
 
25
#include <drizzled/plugin/client.h>
 
26
 
 
27
namespace drizzled
 
28
{
28
29
 
29
30
/*
30
31
  When a user variable is updated (in a SET command or a query like
36
37
  assert(fixed == 0);
37
38
  /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */
38
39
  if (Item_func::fix_fields(session, ref) ||
39
 
      !(entry= get_variable(&session->user_vars, name, 1)))
 
40
      !(entry= session->getVariable(name, true)))
40
41
    return true;
41
42
  /*
42
43
     Remember the last query which updated it, this way a query can later know
43
44
     if this variable is a constant item in the query (it is if update_query_id
44
45
     is different from query_id).
45
46
  */
46
 
  entry->update_query_id= session->query_id;
 
47
  entry->update_query_id= session->getQueryId();
47
48
  /*
48
49
    As it is wrong and confusing to associate any
49
50
    character set with NULL, @a should be latin2
89
90
  if (result_field)
90
91
  {
91
92
    Table *table= (Table *) arg;
92
 
    if (result_field->table == table || !table)
93
 
      bitmap_set_bit(result_field->table->read_set, result_field->field_index);
94
 
    if (result_field->vcol_info && result_field->vcol_info->expr_item)
95
 
      return result_field->vcol_info->
96
 
               expr_item->walk(&Item::register_field_in_read_map, 1, arg);
97
 
  }
98
 
  return 0;
99
 
}
100
 
 
101
 
/*
102
 
  Mark field in bitmap supplied as *arg
103
 
 
104
 
*/
105
 
 
106
 
bool Item_func_set_user_var::register_field_in_bitmap(unsigned char *arg)
107
 
{
108
 
  MY_BITMAP *bitmap = (MY_BITMAP *) arg;
109
 
  assert(bitmap);
110
 
  if (result_field)
111
 
  {
112
 
    bitmap_set_bit(bitmap, result_field->field_index);
113
 
  }
114
 
  return 0;
115
 
}
 
93
    if (result_field->getTable() == table || !table)
 
94
      result_field->getTable()->setReadSet(result_field->field_index);
 
95
  }
 
96
  return 0;
 
97
}
 
98
 
116
99
 
117
100
bool
118
101
Item_func_set_user_var::update_hash(void *ptr, uint32_t length,
126
109
  */
127
110
  if ((null_value= args[0]->null_value) && null_item)
128
111
    res_type= entry->type;                      // Don't change type of item
129
 
  if (::update_hash(entry, (null_value= args[0]->null_value),
130
 
                    ptr, length, res_type, cs, dv, unsigned_arg))
 
112
  if (entry->update_hash((null_value= args[0]->null_value),
 
113
                         ptr, length, res_type, cs, dv, unsigned_arg))
131
114
  {
132
115
    null_value= 1;
133
116
    return 1;
333
316
  str->append(')');
334
317
}
335
318
 
336
 
 
337
 
void Item_func_set_user_var::print_as_stmt(String *str,
338
 
                                           enum_query_type query_type)
339
 
{
340
 
  str->append(STRING_WITH_LEN("set @"));
341
 
  str->append(name.str, name.length);
342
 
  str->append(STRING_WITH_LEN(":="));
343
 
  args[0]->print(str, query_type);
344
 
  str->append(')');
345
 
}
346
 
 
347
 
bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg)
 
319
bool Item_func_set_user_var::send(plugin::Client *client, String *str_arg)
348
320
{
349
321
  if (result_field)
350
322
  {
351
323
    check(1);
352
324
    update();
353
 
    return protocol->store(result_field);
 
325
    return client->store(result_field);
354
326
  }
355
 
  return Item::send(protocol, str_arg);
 
327
  return Item::send(client, str_arg);
356
328
}
357
329
 
358
 
void Item_func_set_user_var::make_field(Send_field *tmp_field)
 
330
void Item_func_set_user_var::make_field(SendField *tmp_field)
359
331
{
360
332
  if (result_field)
361
333
  {
467
439
}
468
440
 
469
441
 
 
442
} /* namespace drizzled */