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

Can't free data returned by mariadb_dyncol_unpack on windows

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.6
    • 10.0.10
    • None
    • None
    • 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().

      Attachments

        Activity

          karlsson Anders Karlsson created issue -
          serg Sergei Golubchik made changes -
          Field Original Value New Value
          Assignee Oleksandr Byelkin [ sanja ]

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

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

          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.

          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.

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

          sanja Oleksandr Byelkin added a comment - my_free should be used, but I do not understand what should be fixed, documentation?
          sanja Oleksandr Byelkin made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          sanja Oleksandr Byelkin made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]

          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

          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
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.8 [ 14200 ]
          serg Sergei Golubchik made changes -
          Assignee Oleksandr Byelkin [ sanja ] Sergei Golubchik [ serg ]

          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()?

          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() ?
          serg Sergei Golubchik made changes -
          Priority Critical [ 2 ] Major [ 3 ]

          mariadb_dyncol_unpack_free() looks quite logical for me...

          sanja Oleksandr Byelkin added a comment - mariadb_dyncol_unpack_free() looks quite logical for me...
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.9 [ 14400 ]
          Fix Version/s 10.0.8 [ 14200 ]

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

          serg Sergei Golubchik added a comment - karlsson do you think we should provide mariadb_dyncol_unpack_free() or something like that?
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.10 [ 14500 ]
          Fix Version/s 10.0.9 [ 14400 ]
          serg Sergei Golubchik made changes -
          Priority Major [ 3 ] Minor [ 4 ]

          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).

          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).
          serg Sergei Golubchik made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          serg Sergei Golubchik made changes -
          Status Stalled [ 10000 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Summary Can't free data retruned by mariadb_dyncol_unpack on windows Can't free data returned by mariadb_dyncol_unpack on windows
          serg Sergei Golubchik made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 30637 ] MariaDB v2 [ 42982 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 42982 ] MariaDB v3 [ 62012 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 62012 ] MariaDB v4 [ 147311 ]

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.