my_bool memc_stats_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { memcached_return rc; memc_function_st *container; /* this is how to fail */ if (args->arg_count != 1) { strncpy(message, "1 argument required: servers, comma-separated: memc_stats(<servers>)", MYSQL_ERRMSG_SIZE); return 1; } args->arg_type[0]= STRING_RESULT; initid->max_length= MEMC_UDF_MAX_SIZE; container= calloc(1, sizeof(memc_function_st)); if (container == NULL) { strncpy(message, "Unable to allocate memory!", MYSQL_ERRMSG_SIZE); return 1; } /* Init the memcached_st we will use for this pass */ rc= memc_get_servers(&container->memc); /* Now setup the string */ container->stats_string= memcached_string_create(&container->memc, NULL, 1024); initid->ptr= (char *)container; return 0; }
my_bool memc_set_by_key_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { memcached_return rc; memc_function_st *container; container= prepare_args(args, message, MEMC_SET_BY_KEY, 3, 4); if (container == NULL) return 1; /* Init the memcached_st we will use for this pass */ rc= memc_get_servers(args, &container->memc); initid->ptr= (char *)container; return (rc == MEMCACHED_SUCCESS ? 0 : 1); }
my_bool memc_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { memcached_return rc; memc_function_st *container; container= prepare_args(args, message, MEMC_DELETE, 1, 2); if (container == NULL) return 1; /* Init the memcached_st we will use for this pass */ rc= memc_get_servers(&container->memc); initid->ptr= (char *)container; return 0; }
my_bool memc_replace_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { unsigned int x; memcached_return rc; memc_function_st *container; container= prepare_args(args, message, MEMC_REPLACE, 2, 3); if (container == NULL) return 1; /* Init the memcached_st we will use for this pass */ rc= memc_get_servers(&container->memc); initid->ptr= (char *)container; return 0; }
my_bool memc_prepend_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { memcached_return rc; memc_function_st *container; container= prepare_args(args, message, MEMC_PREPEND, 2, 3); if (container == NULL) { fprintf(stderr, "errors\n"); return 1; } /* Init the memcached_st we will use for this pass */ rc= memc_get_servers(&container->memc); initid->ptr= (char *)container; return 0; }