Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:55:46+00:00 2026-05-25T10:55:46+00:00

This is my first time trying to create an udf for mysql. The docs

  • 0

This is my first time trying to create an udf for mysql. The docs state that my_func_init gets called prior to executing the main function, yet in my environment this does not seem to happen.

long long charmatch(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
{
    return 42;
}

my_bool charmatch_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
    if (args->arg_count != 2)
    {
        strncpy(message, "charmatch() requires two arguments", 34);
        return EXIT_FAILURE;
        // was return EXIT_SUCCESS;
    }

    if(args->arg_type[0] != STRING_RESULT)
    {
        strncpy(message, "argument 1 must be a string", 27);
        return EXIT_FAILURE;
        // was return EXIT_SUCCESS;
    }

    if(args->arg_type[0] != STRING_RESULT)
    {
        strncpy(message, "argument 2 must be a string", 27);
        return EXIT_FAILURE;
        // was return EXIT_SUCCESS;
    }

    return EXIT_SUCCESS;
}

As you can see, I’m checking whether there are two arguments. In theory SELECT CHARMATCH() should return a message saying I must set two arguments, but it’s not: it return 42.

Why doesn’t it return the message?

EDIT Seems like the problem was in my return values for errors being 0 instead of 1. I fixed it and now calling SELECT CHARMATCH() with the wrong number of arguments returns an empty set. Why are the errors not being displayed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:55:47+00:00Added an answer on May 25, 2026 at 10:55 am

    You always return EXIT_SUCCESS in charmatch_init(), but

    “The initialization function should return 0 if no error occurred and 1 otherwise. If an error occurs, xxx_init() should store a null-terminated error message in the message parameter. ”

    http://dev.mysql.com/doc/refman/5.0/en/udf-return-values.html

    I guess that’s why your error messages are ignored.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using XSLT. I'm trying to create a file that
This is my first time using a webservice and I' trying to create a
This is my first time working with python. I'm trying to create a dictionary
Sorry this is my first time trying to create a plugin, so I might
I'm trying to create a popup window that only appears the first time the
This is my first time working with Objective-C, and I keep trying to create
this is my first time trying to use document classes in AS3 and im
This is the first time I'm trying random numbers with C (I miss C#).
This is my first time making a hash table. I'm trying to associate strings
Disclaimer: This is my first time writing unit tests...be gentle! :) I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.