Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5404

Can't free data returned by mariadb_dyncol_unpack on windows

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0.6
    • Fix Version/s: 10.0.10
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 7 32-bit application using Visual Studio Express 2012

      Description

      Using the libmysql client you can unpack a dynamic column using mariadb_dyncol_unpack(), but the data returned in the column_keys and values needs to be freed after use. It is not documented how to do this (i.e. which free function to call) but neither free(), HeapFree() or mariadb_dyncol_free() works. Looking at the code, sf_malloc is used to allocate the data but I can's see a corresponding function that will free data using sf_free().

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            As far as I understand, you should use my_free() for this.

            Show
            serg Sergei Golubchik added a comment - As far as I understand, you should use my_free() for this.
            Hide
            karlsson Anders Karlsson added a comment -

            Sure, that's what I could see in the libmysqld source also. The issue is that my_free() isn't exported from libmysqld, nor is this documented, so I figured it might change and if my_free() really is to be used, then make sure my_free() is exported, make sure my_free() is documented and make sure to document that my_free() should be used for this purpose.

            Show
            karlsson Anders Karlsson added a comment - Sure, that's what I could see in the libmysqld source also. The issue is that my_free() isn't exported from libmysqld, nor is this documented, so I figured it might change and if my_free() really is to be used, then make sure my_free() is exported, make sure my_free() is documented and make sure to document that my_free() should be used for this purpose.
            Hide
            sanja Oleksandr Byelkin added a comment -

            my_free should be used, but I do not understand what should be fixed, documentation?

            Show
            sanja Oleksandr Byelkin added a comment - my_free should be used, but I do not understand what should be fixed, documentation?
            Hide
            karlsson Anders Karlsson added a comment -

            Two things: Documentation and, on Windows, make sure that my_free is exported from the .dll. The following samle program:
            #include <stdio.h>
            #include <my_global.h>
            #include <mysql.h>
            #include <ma_dyncol.h>

            int main(int argc, char* argv[])
            {
            DYNAMIC_COLUMN dc;
            DYNAMIC_COLUMN_VALUE dcv[1];
            uint colno[] =

            {1}

            ;

            dcv[0].type = DYN_COL_INT;
            dcv[0].x.long_value = 1;
            mariadb_dyncol_create_many_num(&dc, 1, colno, dcv, TRUE);
            my_free(dc.str);
            return 0;
            }
            Compiles and runs nicely on Linux, but on Windows I get:
            Error 2 error C3861: 'my_free': identifier not found c:\programming\src\consoleapplication1\consoleapplication1\consoleapplication1.cpp 14 1 ConsoleApplication1
            Tested with MariaDB 10.0.7 on both Linux and WIndows

            Show
            karlsson Anders Karlsson added a comment - Two things: Documentation and, on Windows, make sure that my_free is exported from the .dll. The following samle program: #include <stdio.h> #include <my_global.h> #include <mysql.h> #include <ma_dyncol.h> int main(int argc, char* argv[]) { DYNAMIC_COLUMN dc; DYNAMIC_COLUMN_VALUE dcv [1] ; uint colno[] = {1} ; dcv [0] .type = DYN_COL_INT; dcv [0] .x.long_value = 1; mariadb_dyncol_create_many_num(&dc, 1, colno, dcv, TRUE); my_free(dc.str); return 0; } Compiles and runs nicely on Linux, but on Windows I get: Error 2 error C3861: 'my_free': identifier not found c:\programming\src\consoleapplication1\consoleapplication1\consoleapplication1.cpp 14 1 ConsoleApplication1 Tested with MariaDB 10.0.7 on both Linux and WIndows
            Hide
            serg Sergei Golubchik added a comment -

            Shall we rather provide mariadb_dyncol_unpack_free() for this? That'd be more logical, than explaining to use my_free(). Any better name than mariadb_dyncol_unpack_free()?

            Show
            serg Sergei Golubchik added a comment - Shall we rather provide mariadb_dyncol_unpack_free() for this? That'd be more logical, than explaining to use my_free() . Any better name than mariadb_dyncol_unpack_free() ?
            Hide
            sanja Oleksandr Byelkin added a comment -

            mariadb_dyncol_unpack_free() looks quite logical for me...

            Show
            sanja Oleksandr Byelkin added a comment - mariadb_dyncol_unpack_free() looks quite logical for me...
            Hide
            serg Sergei Golubchik added a comment -

            Anders Karlsson do you think we should provide mariadb_dyncol_unpack_free() or something like that?

            Show
            serg Sergei Golubchik added a comment - Anders Karlsson do you think we should provide mariadb_dyncol_unpack_free() or something like that?
            Hide
            karlsson Anders Karlsson added a comment -

            Yes, mariadb_dyncol_unpack_free() solves the problem and looks logical. Just make that this is exported from the DLL on Windows (my_free() is not exported on Windows, so on that platform the workaround to just call my_free() doesn't work there. This was true in 10.0.7 at least).

            Show
            karlsson Anders Karlsson added a comment - Yes, mariadb_dyncol_unpack_free() solves the problem and looks logical. Just make that this is exported from the DLL on Windows (my_free() is not exported on Windows, so on that platform the workaround to just call my_free() doesn't work there. This was true in 10.0.7 at least).

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                karlsson Anders Karlsson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 20 minutes
                  20m