[MDEV-5404] Can't free data returned by mariadb_dyncol_unpack on windows Created: 2013-12-06  Updated: 2014-03-26  Resolved: 2014-03-26

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.6
Fix Version/s: 10.0.10

Type: Bug Priority: Major
Reporter: Anders Karlsson Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
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().



 Comments   
Comment by Sergei Golubchik [ 2013-12-06 ]

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

Comment by Anders Karlsson [ 2013-12-06 ]

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.

Comment by Oleksandr Byelkin [ 2014-01-17 ]

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

Comment by Anders Karlsson [ 2014-01-17 ]

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

Comment by Sergei Golubchik [ 2014-02-06 ]

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

Comment by Oleksandr Byelkin [ 2014-02-06 ]

mariadb_dyncol_unpack_free() looks quite logical for me...

Comment by Sergei Golubchik [ 2014-02-25 ]

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

Comment by Anders Karlsson [ 2014-03-18 ]

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

Generated at Thu Feb 08 07:04:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.