The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.

Unable to create user-defined function in C++

While I try to deploying user-defined function developed in C++, I'm getting this error "Tried to copy a 20-byte string to 7-byte VString object; VString is too small". Kindly help me with this. Thanks in advance.

Comments

  • skeswaniskeswani Employee

    can you post your code?

  • edited June 18

    @skeswani Please find an attached text file

  • skeswaniskeswani Employee
    edited June 18

    the problem I think is here

    returnType.addVarchar(t.getStringLength());

    this result in the copy of a buf which is 20 bytes into a response that is 7 bytes

    resWriter.getStringRef().copy(buf);

    change this to

    returnType.addVarchar(20) ;

    note, putting s '>' sign before the line will help format the code correctly in the forums

  • skeswaniskeswani Employee

    20 or more, this is the output return type for the scalar function. basically the scalar function return varchar(20) in this case. but maybe you want to make it varchar(32) for good measure

  • @skeswani Thanks its work.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.