~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_udf.cc

Resolving conflicts for a few files regarding FALSE=>false

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
  READ_RECORD read_record_info;
114
114
  TABLE *table;
115
115
  int error;
116
 
  DBUG_ENTER("ufd_init");
 
116
  
117
117
  char db[]= "mysql"; /* A subject to casednstr, can't be constant */
118
118
 
119
119
  if (initialized)
120
 
    DBUG_VOID_RETURN;
 
120
    return;
121
121
 
122
122
  my_rwlock_init(&THR_LOCK_udf,NULL);
123
123
  
130
130
    hash_free(&udf_hash);
131
131
    free_root(&mem,MYF(0));
132
132
    delete new_thd;
133
 
    DBUG_VOID_RETURN;
 
133
    return;
134
134
  }
135
135
  initialized = 1;
136
136
  new_thd->thread_stack= (char*) &new_thd;
145
145
 
146
146
  if (simple_open_n_lock_tables(new_thd, &tables))
147
147
  {
148
 
    DBUG_PRINT("error",("Can't open udf table"));
149
148
    sql_print_error("Can't open the mysql.func table. Please "
150
149
                    "run mysql_upgrade to create it.");
151
150
    goto end;
156
155
  table->use_all_columns();
157
156
  while (!(error= read_record_info.read_record(&read_record_info)))
158
157
  {
159
 
    DBUG_PRINT("info",("init udf record"));
160
158
    LEX_STRING name;
161
159
    name.str=get_field(&mem, table->field[0]);
162
160
    name.length = strlen(name.str);
228
226
  delete new_thd;
229
227
  /* Remember that we don't have a THD */
230
228
  my_pthread_setspecific_ptr(THR_THD,  0);
231
 
  DBUG_VOID_RETURN;
 
229
  return;
232
230
}
233
231
 
234
232
 
235
233
void udf_free()
236
234
{
237
235
  /* close all shared libraries */
238
 
  DBUG_ENTER("udf_free");
 
236
  
239
237
  for (uint idx=0 ; idx < udf_hash.records ; idx++)
240
238
  {
241
239
    udf_func *udf=(udf_func*) hash_element(&udf_hash,idx);
258
256
    initialized= 0;
259
257
    rwlock_destroy(&THR_LOCK_udf);
260
258
  }
261
 
  DBUG_VOID_RETURN;
 
259
  return;
262
260
}
263
261
 
264
262
 
265
263
static void del_udf(udf_func *udf)
266
264
{
267
 
  DBUG_ENTER("del_udf");
 
265
  
268
266
  if (!--udf->usage_count)
269
267
  {
270
268
    hash_delete(&udf_hash,(uchar*) udf);
283
281
    udf->name.length=1;
284
282
    hash_update(&udf_hash,(uchar*) udf,(uchar*) name,name_length);
285
283
  }
286
 
  DBUG_VOID_RETURN;
 
284
  return;
287
285
}
288
286
 
289
287
 
290
288
void free_udf(udf_func *udf)
291
289
{
292
 
  DBUG_ENTER("free_udf");
 
290
  
293
291
  
294
292
  if (!initialized)
295
 
    DBUG_VOID_RETURN;
 
293
    return;
296
294
 
297
295
  rw_wrlock(&THR_LOCK_udf);
298
296
  if (!--udf->usage_count)
307
305
      dlclose(udf->dlhandle);
308
306
  }
309
307
  rw_unlock(&THR_LOCK_udf);
310
 
  DBUG_VOID_RETURN;
 
308
  return;
311
309
}
312
310
 
313
311
 
316
314
udf_func *find_udf(const char *name,uint length,bool mark_used)
317
315
{
318
316
  udf_func *udf=0;
319
 
  DBUG_ENTER("find_udf");
 
317
  
320
318
 
321
319
  if (!initialized)
322
 
    DBUG_RETURN(NULL);
 
320
    return(NULL);
323
321
 
324
322
  /* TODO: This should be changed to reader locks someday! */
325
323
  if (mark_used)
336
334
      udf->usage_count++;
337
335
  }
338
336
  rw_unlock(&THR_LOCK_udf);
339
 
  DBUG_RETURN(udf);
 
337
  return(udf);
340
338
}
341
339
 
342
340
 
343
341
static void *find_udf_dl(const char *dl)
344
342
{
345
 
  DBUG_ENTER("find_udf_dl");
 
343
  
346
344
 
347
345
  /*
348
346
    Because only the function name is hashed, we have to search trough
352
350
  {
353
351
    udf_func *udf=(udf_func*) hash_element(&udf_hash,idx);
354
352
    if (!strcmp(dl, udf->dl) && udf->dlhandle != NULL)
355
 
      DBUG_RETURN(udf->dlhandle);
 
353
      return(udf->dlhandle);
356
354
  }
357
 
  DBUG_RETURN(0);
 
355
  return(0);
358
356
}
359
357
 
360
358
 
397
395
  TABLE *table;
398
396
  TABLE_LIST tables;
399
397
  udf_func *u_d;
400
 
  DBUG_ENTER("mysql_create_function");
 
398
  
401
399
 
402
400
  if (!initialized)
403
401
  {
407
405
               "UDFs are unavailable with the --skip-grant-tables option");
408
406
    else
409
407
      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
410
 
    DBUG_RETURN(1);
 
408
    return(1);
411
409
  }
412
410
 
413
411
  /*
423
421
                       udf->dl + strlen(udf->dl), '/'), 0))
424
422
  {
425
423
    my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
426
 
    DBUG_RETURN(1);
 
424
    return(1);
427
425
  }
428
426
  if (check_identifier_name(&udf->name, ER_TOO_LONG_IDENT))
429
 
    DBUG_RETURN(1);
 
427
    return(1);
430
428
 
431
429
  /* 
432
430
    Turn off row binlogging of this statement and use statement-based 
501
499
  /* Binlog the create function. */
502
500
  write_bin_log(thd, TRUE, thd->query, thd->query_length);
503
501
 
504
 
  DBUG_RETURN(0);
 
502
  return(0);
505
503
 
506
504
 err:
507
505
  if (new_dl)
508
506
    dlclose(dl);
509
507
  rw_unlock(&THR_LOCK_udf);
510
 
  DBUG_RETURN(1);
 
508
  return(1);
511
509
}
512
510
 
513
511
 
518
516
  udf_func *udf;
519
517
  char *exact_name_str;
520
518
  uint exact_name_len;
521
 
  DBUG_ENTER("mysql_drop_function");
 
519
  
522
520
 
523
521
  if (!initialized)
524
522
  {
526
524
      my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str);
527
525
    else
528
526
      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
529
 
    DBUG_RETURN(1);
 
527
    return(1);
530
528
  }
531
529
 
532
530
  /* 
576
574
  /* Binlog the drop function. */
577
575
  write_bin_log(thd, TRUE, thd->query, thd->query_length);
578
576
 
579
 
  DBUG_RETURN(0);
 
577
  return(0);
580
578
 err:
581
579
  rw_unlock(&THR_LOCK_udf);
582
 
  DBUG_RETURN(1);
 
580
  return(1);
583
581
}
584
582
 
585
583
#endif /* HAVE_DLOPEN */