~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_plugin.cc

Removed/replaced BUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#define REPORT_TO_LOG  1
20
20
#define REPORT_TO_USER 2
21
21
 
22
 
#ifdef DBUG_OFF
23
 
#define plugin_ref_to_int(A) A
24
 
#define plugin_int_to_ref(A) A
25
 
#else
26
22
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
27
23
#define plugin_int_to_ref(A) &(A)
28
 
#endif
29
24
 
30
25
extern struct st_mysql_plugin *mysqld_builtins[];
31
26
 
437
432
        When the following assert starts failing, we'll have to switch
438
433
        to the upper branch of the #ifdef
439
434
      */
440
 
      DBUG_ASSERT(min_plugin_interface_version == 0);
 
435
      assert(min_plugin_interface_version == 0);
441
436
      sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
442
437
#endif
443
438
    }
596
591
  if (pi->state & (PLUGIN_IS_READY | PLUGIN_IS_UNINITIALIZED))
597
592
  {
598
593
    plugin_ref plugin;
599
 
#ifdef DBUG_OFF
600
 
    /* built-in plugins don't need ref counting */
601
 
    if (!pi->plugin_dl)
602
 
      return(pi);
603
 
 
604
 
    plugin= pi;
605
 
#else
606
594
    /*
607
595
      For debugging, we do an additional malloc which allows the
608
596
      memory manager and/or valgrind to track locked references and
612
600
      return(NULL);
613
601
 
614
602
    *plugin= pi;
615
 
#endif
616
603
    pi->ref_count++;
617
604
 
618
605
    if (lex)
887
874
        delete_dynamic_element(&lex->plugins, i);
888
875
        break;
889
876
      }
890
 
    DBUG_ASSERT(i >= 0);
 
877
    assert(i >= 0);
891
878
  }
892
879
 
893
 
  DBUG_ASSERT(pi->ref_count);
 
880
  assert(pi->ref_count);
894
881
  pi->ref_count--;
895
882
 
896
883
  if (pi->state == PLUGIN_IS_DELETED && !pi->ref_count)
914
901
void plugin_unlock_list(THD *thd, plugin_ref *list, uint count)
915
902
{
916
903
  LEX *lex= thd ? thd->lex : 0;
917
 
  DBUG_ASSERT(list);
 
904
  assert(list);
918
905
  while (count--)
919
906
    intern_plugin_unlock(lex, *list++);
920
907
  reap_plugins();
1090
1077
      */
1091
1078
      if (is_myisam)
1092
1079
      {
1093
 
        DBUG_ASSERT(!global_system_variables.table_plugin);
 
1080
        assert(!global_system_variables.table_plugin);
1094
1081
        global_system_variables.table_plugin=
1095
1082
          my_intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr));
1096
 
        DBUG_ASSERT(plugin_ptr->ref_count == 1);
 
1083
        assert(plugin_ptr->ref_count == 1);
1097
1084
      }
1098
1085
    }
1099
1086
  }
1100
1087
 
1101
1088
  /* should now be set to MyISAM storage engine */
1102
 
  DBUG_ASSERT(global_system_variables.table_plugin);
 
1089
  assert(global_system_variables.table_plugin);
1103
1090
 
1104
1091
  /* Register all dynamic plugins */
1105
1092
  if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING))
1897
1884
    size= sizeof(char*);
1898
1885
    break;
1899
1886
  default:
1900
 
    DBUG_ASSERT(0);
 
1887
    assert(0);
1901
1888
    return NULL;
1902
1889
  };
1903
1890
 
1916
1903
    result->name_len= length - 2;
1917
1904
    result->offset= -1;
1918
1905
 
1919
 
    DBUG_ASSERT(size && !(size & (size-1))); /* must be power of 2 */
 
1906
    assert(size && !(size & (size-1))); /* must be power of 2 */
1920
1907
 
1921
1908
    offset= global_system_variables.dynamic_variables_size;
1922
1909
    offset= (offset + size - 1) & ~(size - 1);
1959
1946
    if (my_hash_insert(&bookmark_hash, (uchar*) result))
1960
1947
    {
1961
1948
      fprintf(stderr, "failed to add placeholder to hash");
1962
 
      DBUG_ASSERT(0);
 
1949
      assert(0);
1963
1950
    }
1964
1951
  }
1965
1952
  my_afree(varname);
1975
1962
*/
1976
1963
static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
1977
1964
{
1978
 
  DBUG_ASSERT(offset >= 0);
1979
 
  DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
 
1965
  assert(offset >= 0);
 
1966
  assert((uint)offset <= global_system_variables.dynamic_variables_head);
1980
1967
 
1981
1968
  if (!thd)
1982
1969
    return (uchar*) global_system_variables.dynamic_variables_ptr + offset;
2127
2114
  }
2128
2115
  rw_unlock(&LOCK_system_variables_hash);
2129
2116
 
2130
 
  DBUG_ASSERT(vars->table_plugin == NULL);
 
2117
  assert(vars->table_plugin == NULL);
2131
2118
 
2132
2119
  my_free(vars->dynamic_variables_ptr, MYF(MY_ALLOW_ZERO_PTR));
2133
2120
  vars->dynamic_variables_ptr= NULL;
2224
2211
  case PLUGIN_VAR_SET:
2225
2212
    return SHOW_CHAR;
2226
2213
  default:
2227
 
    DBUG_ASSERT(0);
 
2214
    assert(0);
2228
2215
    return SHOW_UNDEF;
2229
2216
  }
2230
2217
}
2232
2219
 
2233
2220
uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
2234
2221
{
2235
 
  DBUG_ASSERT(thd || (type == OPT_GLOBAL));
 
2222
  assert(thd || (type == OPT_GLOBAL));
2236
2223
  if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
2237
2224
  {
2238
2225
    if (type == OPT_GLOBAL)
2299
2286
bool sys_var_pluginvar::check(THD *thd, set_var *var)
2300
2287
{
2301
2288
  st_item_value_holder value;
2302
 
  DBUG_ASSERT(is_readonly() || plugin_var->check);
 
2289
  assert(is_readonly() || plugin_var->check);
2303
2290
 
2304
2291
  value.value_type= item_value_type;
2305
2292
  value.val_str= item_val_str;
2317
2304
  const void *src;
2318
2305
  void *tgt;
2319
2306
 
2320
 
  DBUG_ASSERT(is_readonly() || plugin_var->update);
 
2307
  assert(is_readonly() || plugin_var->update);
2321
2308
 
2322
2309
  if (is_readonly())
2323
2310
    return;
2354
2341
          src= &((thdvar_str_t*) plugin_var)->def_val;
2355
2342
          break;
2356
2343
        default:
2357
 
          DBUG_ASSERT(0);
 
2344
          assert(0);
2358
2345
        }
2359
2346
  }
2360
2347
 
2361
2348
  /* thd must equal current_thd if PLUGIN_VAR_THDLOCAL flag is set */
2362
 
  DBUG_ASSERT(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
 
2349
  assert(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
2363
2350
              thd == current_thd);
2364
2351
 
2365
2352
  if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
2379
2366
{
2380
2367
  void *tgt;
2381
2368
 
2382
 
  DBUG_ASSERT(is_readonly() || plugin_var->update);
 
2369
  assert(is_readonly() || plugin_var->update);
2383
2370
 
2384
2371
  /* thd must equal current_thd if PLUGIN_VAR_THDLOCAL flag is set */
2385
 
  DBUG_ASSERT(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
 
2372
  assert(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
2386
2373
              thd == current_thd);
2387
2374
 
2388
2375
  if (is_readonly())
2506
2493
    options->def_value= (intptr) ((thdvar_str_t*) opt)->def_val;
2507
2494
    break;
2508
2495
  default:
2509
 
    DBUG_ASSERT(0);
 
2496
    assert(0);
2510
2497
  }
2511
2498
  options->arg_type= REQUIRED_ARG;
2512
2499
  if (opt->flags & PLUGIN_VAR_NOCMDARG)
2807
2794
  sys_var *v;
2808
2795
  struct st_bookmark *var;
2809
2796
  uint len, count= EXTRA_OPTIONS;
2810
 
  DBUG_ASSERT(tmp->plugin && tmp->name.str);
 
2797
  assert(tmp->plugin && tmp->name.str);
2811
2798
 
2812
2799
  for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
2813
2800
    count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
2872
2859
 
2873
2860
        v= new (mem_root) sys_var_pluginvar(varname, o);
2874
2861
      }
2875
 
      DBUG_ASSERT(v); /* check that an object was actually constructed */
 
2862
      assert(v); /* check that an object was actually constructed */
2876
2863
 
2877
2864
      /*
2878
2865
        Add to the chain of variables.