1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-01 06:27:04 +03:00

Partial revert of 1a2ed3f67a

Since Item_result enumerations are also used by MariaDB server, we
moved them back to mariadb_com.h.
Item_result is not used in Connector/C 3.3 and above for replication
api.
This commit is contained in:
Georg Richter
2024-12-22 11:00:12 +01:00
parent 80a7fa5cee
commit 12a7054194
3 changed files with 51 additions and 8 deletions

View File

@ -68,6 +68,20 @@ ADD_OPTION(WITH_CURL "Enables use of curl" ON)
ADD_OPTION(WITH_SSL "Enables use of TLS/SSL library" ON)
###############
if (WITH_ASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -static-libasan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover=all")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-common")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-address-use-after-scope")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=alignment")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=null")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=vptr")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan")
endif()
INCLUDE(${CC_SOURCE_DIR}/cmake/misc.cmake)
INCLUDE(FindCURL)

View File

@ -59,6 +59,8 @@ enum mysql_enum_shutdown_level
KILL_CONNECTION= 255
};
enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT,ROW_RESULT,DECIMAL_RESULT};
enum enum_server_command
{
COM_SLEEP = 0,

View File

@ -879,6 +879,35 @@ static size_t rset_field_offsets[]= {
OFFSET(MYSQL_FIELD, org_name_length)
};
/* calculate lengths for field metadata:
returns zero on success, 1 if null_length was
detected */
static my_bool ma_get_rset_field_lengths(MYSQL_ROW row, unsigned int field_count,
unsigned long *lengths)
{
unsigned long *last_length= 0;
char *pos= 0;
MYSQL_ROW end= row + field_count + 1;
my_bool rc= 0;
while (row != end)
{
if (*row)
{
if (pos)
*last_length= (ulong)(*row - pos - 1);
pos= *row;
} else {
/* NULL_LENGTH (see also CONC-709) */
rc= 1;
*last_length= 0;
}
last_length= lengths++;
row++;
}
return rc;
}
MYSQL_FIELD *
unpack_fields(const MYSQL *mysql,
MYSQL_DATA *data, MA_MEM_ROOT *alloc, uint fields,
@ -895,21 +924,19 @@ unpack_fields(const MYSQL *mysql,
for (row=data->data; row ; row = row->next,field++)
{
unsigned long lengths[9];
if (field >= result + fields)
goto error;
if (ma_get_rset_field_lengths(row->data, field_count, lengths))
goto error;
for (i=0; i < field_count; i++)
{
uint length;
if (!row->data[i])
goto error;
length= (uint)(row->data[i+1] - row->data[i] - 1);
*(char **)(((char *)field) + rset_field_offsets[i*2])=
ma_strdup_root(alloc, (char *)row->data[i]);
*(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1])= length;
*(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1])= lengths[i];
}
field->extension= NULL;