~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_strfunc.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
 
48
48
 
49
 
bool Item_str_func::fix_fields(Session *thd, Item **ref)
 
49
bool Item_str_func::fix_fields(Session *session, Item **ref)
50
50
{
51
 
  bool res= Item_func::fix_fields(thd, ref);
 
51
  bool res= Item_func::fix_fields(session, ref);
52
52
  /*
53
53
    In Item_str_func::check_well_formed_result() we may set null_value
54
54
    flag on the same condition as in test() below.
130
130
      if (res2->length() == 0)
131
131
        continue;
132
132
      if (res->length()+res2->length() >
133
 
          current_thd->variables.max_allowed_packet)
 
133
          current_session->variables.max_allowed_packet)
134
134
      {
135
 
        push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
135
        push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
136
136
                            ER_WARN_ALLOWED_PACKET_OVERFLOWED,
137
137
                            ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), func_name(),
138
 
                            current_thd->variables.max_allowed_packet);
 
138
                            current_session->variables.max_allowed_packet);
139
139
        goto null;
140
140
      }
141
141
      if (!is_const && res->alloced_length() >= res->length()+res2->length())
291
291
      continue;                                 // Skip NULL
292
292
 
293
293
    if (res->length() + sep_str->length() + res2->length() >
294
 
        current_thd->variables.max_allowed_packet)
 
294
        current_session->variables.max_allowed_packet)
295
295
    {
296
 
      push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
296
      push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
297
297
                          ER_WARN_ALLOWED_PACKET_OVERFLOWED,
298
298
                          ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), func_name(),
299
 
                          current_thd->variables.max_allowed_packet);
 
299
                          current_session->variables.max_allowed_packet);
300
300
      goto null;
301
301
    }
302
302
    if (res->alloced_length() >=
548
548
            if (*i++ != *j++) goto skip;
549
549
          offset= (int) (ptr-res->ptr());
550
550
          if (res->length()-from_length + to_length >
551
 
              current_thd->variables.max_allowed_packet)
 
551
              current_session->variables.max_allowed_packet)
552
552
          {
553
 
            push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
553
            push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
554
554
                                ER_WARN_ALLOWED_PACKET_OVERFLOWED,
555
555
                                ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
556
556
                                func_name(),
557
 
                                current_thd->variables.max_allowed_packet);
 
557
                                current_session->variables.max_allowed_packet);
558
558
 
559
559
            goto null;
560
560
          }
577
577
    do
578
578
    {
579
579
      if (res->length()-from_length + to_length >
580
 
          current_thd->variables.max_allowed_packet)
 
580
          current_session->variables.max_allowed_packet)
581
581
      {
582
 
        push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
582
        push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
583
583
                            ER_WARN_ALLOWED_PACKET_OVERFLOWED,
584
584
                            ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), func_name(),
585
 
                            current_thd->variables.max_allowed_packet);
 
585
                            current_session->variables.max_allowed_packet);
586
586
        goto null;
587
587
      }
588
588
      if (!alloced)
655
655
    length= res->length() - start;
656
656
 
657
657
  if ((uint64_t) (res->length() - length + res2->length()) >
658
 
      (uint64_t) current_thd->variables.max_allowed_packet)
 
658
      (uint64_t) current_session->variables.max_allowed_packet)
659
659
  {
660
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
660
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
661
661
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
662
662
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
663
 
                        func_name(), current_thd->variables.max_allowed_packet);
 
663
                        func_name(), current_session->variables.max_allowed_packet);
664
664
    goto null;
665
665
  }
666
666
  res=copy_if_not_alloced(str,res,res->length());
1276
1276
String *Item_func_database::val_str(String *str)
1277
1277
{
1278
1278
  assert(fixed == 1);
1279
 
  Session *thd= current_thd;
1280
 
  if (thd->db == NULL)
 
1279
  Session *session= current_session;
 
1280
  if (session->db == NULL)
1281
1281
  {
1282
1282
    null_value= 1;
1283
1283
    return 0;
1284
1284
  }
1285
1285
  else
1286
 
    str->copy(thd->db, thd->db_length, system_charset_info);
 
1286
    str->copy(session->db, session->db_length, system_charset_info);
1287
1287
  return str;
1288
1288
}
1289
1289
 
1317
1317
}
1318
1318
 
1319
1319
 
1320
 
bool Item_func_user::fix_fields(Session *thd, Item **ref)
 
1320
bool Item_func_user::fix_fields(Session *session, Item **ref)
1321
1321
{
1322
 
  return (Item_func_sysconst::fix_fields(thd, ref) ||
1323
 
          init(thd->main_security_ctx.user,
1324
 
               thd->main_security_ctx.ip));
 
1322
  return (Item_func_sysconst::fix_fields(session, ref) ||
 
1323
          init(session->main_security_ctx.user,
 
1324
               session->main_security_ctx.ip));
1325
1325
}
1326
1326
 
1327
1327
 
1328
 
bool Item_func_current_user::fix_fields(Session *thd, Item **ref)
 
1328
bool Item_func_current_user::fix_fields(Session *session, Item **ref)
1329
1329
{
1330
 
  if (Item_func_sysconst::fix_fields(thd, ref))
 
1330
  if (Item_func_sysconst::fix_fields(session, ref))
1331
1331
    return true;
1332
1332
 
1333
1333
  Security_context *ctx=
1334
 
                         thd->security_ctx;
 
1334
                         session->security_ctx;
1335
1335
  return init(ctx->user, ctx->ip);
1336
1336
}
1337
1337
 
1509
1509
}
1510
1510
 
1511
1511
 
1512
 
void Item_func_make_set::split_sum_func(Session *thd, Item **ref_pointer_array,
 
1512
void Item_func_make_set::split_sum_func(Session *session, Item **ref_pointer_array,
1513
1513
                                        List<Item> &fields)
1514
1514
{
1515
 
  item->split_sum_func2(thd, ref_pointer_array, fields, &item, true);
1516
 
  Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
 
1515
  item->split_sum_func2(session, ref_pointer_array, fields, &item, true);
 
1516
  Item_str_func::split_sum_func(session, ref_pointer_array, fields);
1517
1517
}
1518
1518
 
1519
1519
 
1609
1609
    change records at each execution.
1610
1610
  */
1611
1611
  if (item != new_item)
1612
 
    current_thd->change_item_tree(&item, new_item);
 
1612
    current_session->change_item_tree(&item, new_item);
1613
1613
  return Item_str_func::transform(transformer, arg);
1614
1614
}
1615
1615
 
1734
1734
    return res;
1735
1735
  length=res->length();
1736
1736
  // Safe length check
1737
 
  if (length > current_thd->variables.max_allowed_packet / (uint) count)
 
1737
  if (length > current_session->variables.max_allowed_packet / (uint) count)
1738
1738
  {
1739
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1739
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1740
1740
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1741
1741
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1742
 
                        func_name(), current_thd->variables.max_allowed_packet);
 
1742
                        func_name(), current_session->variables.max_allowed_packet);
1743
1743
    goto err;
1744
1744
  }
1745
1745
  tot_length= length*(uint) count;
1824
1824
  pad_char_length= rpad->numchars();
1825
1825
 
1826
1826
  byte_count= count * collation.collation->mbmaxlen;
1827
 
  if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
 
1827
  if ((uint64_t) byte_count > current_session->variables.max_allowed_packet)
1828
1828
  {
1829
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1829
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1830
1830
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1831
1831
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1832
 
                        func_name(), current_thd->variables.max_allowed_packet);
 
1832
                        func_name(), current_session->variables.max_allowed_packet);
1833
1833
    goto err;
1834
1834
  }
1835
1835
  if (args[2]->null_value || !pad_char_length)
1929
1929
  pad_char_length= pad->numchars();
1930
1930
  byte_count= count * collation.collation->mbmaxlen;
1931
1931
  
1932
 
  if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
 
1932
  if ((uint64_t) byte_count > current_session->variables.max_allowed_packet)
1933
1933
  {
1934
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1934
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1935
1935
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1936
1936
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1937
 
                        func_name(), current_thd->variables.max_allowed_packet);
 
1937
                        func_name(), current_session->variables.max_allowed_packet);
1938
1938
    goto err;
1939
1939
  }
1940
1940
 
2291
2291
    /* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */
2292
2292
    goto err;
2293
2293
  }
2294
 
  if (stat_info.st_size > (long) current_thd->variables.max_allowed_packet)
 
2294
  if (stat_info.st_size > (long) current_session->variables.max_allowed_packet)
2295
2295
  {
2296
 
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
2296
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2297
2297
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
2298
2298
                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
2299
 
                        func_name(), current_thd->variables.max_allowed_packet);
 
2299
                        func_name(), current_session->variables.max_allowed_packet);
2300
2300
    goto err;
2301
2301
  }
2302
2302
  if (tmp_value.alloc(stat_info.st_size))
2540
2540
{
2541
2541
  assert(fixed == 1);
2542
2542
  char *s;
2543
 
  Session *thd= current_thd;
 
2543
  Session *session= current_session;
2544
2544
 
2545
2545
  pthread_mutex_lock(&LOCK_uuid_generator);
2546
2546
  if (! uuid_time) /* first UUID() call. initializing data */
2557
2557
        with a clock_seq value (initialized random below), we use a separate
2558
2558
        randominit() here
2559
2559
      */
2560
 
      randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)global_query_id);
 
2560
      randominit(&uuid_rand, tmp + (ulong) session, tmp + (ulong)global_query_id);
2561
2561
      for (i=0; i < (int)sizeof(mac); i++)
2562
2562
        mac[i]=(unsigned char)(my_rnd(&uuid_rand)*255);
2563
2563
      /* purecov: end */    
2569
2569
      *--s=_dig_vec_lower[mac[i] >> 4];
2570
2570
    }
2571
2571
    randominit(&uuid_rand, tmp + (ulong) server_start_time,
2572
 
               tmp + (ulong) thd->status_var.bytes_sent);
 
2572
               tmp + (ulong) session->status_var.bytes_sent);
2573
2573
    set_clock_seq_str();
2574
2574
  }
2575
2575