Skip to content

Commit

Permalink
Build fix on Linux
Browse files Browse the repository at this point in the history
Fixed case of some source filenames in cmake and other build issues

That prevented build of the driver on linux. Added missing stddef.h
inclusion to ma_dsn.c, in particular.

Fixed setup dialog lib build

Fixed some compilation warnings.

Suppressed C/C tests and MSI build by default
  • Loading branch information
lawrinn committed Mar 28, 2023
1 parent eaf9c33 commit b72749f
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 87 deletions.
7 changes: 5 additions & 2 deletions cmake/options_defaults.cmake
@@ -1,5 +1,5 @@
#
# Copyright (C) 2021 MariaDB Corporation AB
# Copyright (C) 2021,2023 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
Expand All @@ -8,9 +8,11 @@

OPTION(BUILD_INTERACTIVE_TESTS "Build test(s) requiring user interaction" OFF)
OPTION(USE_INTERACTIVE_TESTS "Run interactive test(s) with ctest" OFF)
OPTION(CONC_WITH_UNIT_TESTS "Build C/C unit tests" OFF)

IF(WIN32)
OPTION(WITH_MSI "Build MSI installation package" ON)
OPTION(CONC_WITH_MSI "Build C/C MSI installation package" OFF)
OPTION(WITH_SIGNCODE "Digitally sign files" OFF)

OPTION(MARIADB_LINK_DYNAMIC "Link Connector/C library dynamically" OFF)
Expand All @@ -19,7 +21,6 @@ IF(WIN32)
# We don't provide its support in ODBC yet, thus there is no need to bloat the library size
#SET(CLIENT_PLUGIN_PVIO_SHMEM "STATIC")
ELSE()
OPTION(WITH_MSI "Build MSI installation package" OFF)
IF(APPLE)
OPTION(MARIADB_LINK_DYNAMIC "Link Connector/C library dynamically" OFF)
ELSE()
Expand Down Expand Up @@ -79,6 +80,8 @@ IF(WIN32)
SET(MARIADB_LINK_DYNAMIC OFF)
ENDIF()
ELSE()
SET(WITH_MSI OFF)
SET(CONC_WITH_MSI OFF)
# Defaults for creating odbc(inst).ini for tests with Unix/iOdbc
IF(WITH_UNIT_TESTS)
SET_VALUE(TEST_DRIVER "maodbc_test")
Expand Down
4 changes: 2 additions & 2 deletions driver/CMakeLists.txt
Expand Up @@ -58,7 +58,7 @@ SET (MARIADB_ODBC_SOURCES odbc_3_api.cpp
class/ColumnDefinition.cpp
class/ResultSetText.cpp
class/ResultSetBin.cpp
class/ResultSetMetadata.cpp
class/ResultSetMetaData.cpp
class/Parameter.cpp
interface/PreparedStatement.cpp
interface/Row.cpp
Expand Down Expand Up @@ -110,7 +110,7 @@ IF(WIN32)
class/ColumnDefinition.h
class/ResultSetText.h
class/ResultSetBin.h
class/ResultSetMetadata.h
class/ResultSetMetaData.h
class/Parameter.h
interface/PreparedStatement.h
interface/PrepareResult.h
Expand Down
4 changes: 2 additions & 2 deletions driver/class/ColumnDefinition.h
Expand Up @@ -74,11 +74,11 @@ class ColumnDefinition
void refreshPointers();

public:
static ColumnDefinition ColumnDefinition::create(const SQLString& name, const MYSQL_FIELD* _type);
static ColumnDefinition create(const SQLString& name, const MYSQL_FIELD* _type);

~ColumnDefinition();
ColumnDefinition(const ColumnDefinition& other);
ColumnDefinition::ColumnDefinition(const ColumnDefinition&& other);
ColumnDefinition(const ColumnDefinition&& other);
ColumnDefinition(const SQLString name, const MYSQL_FIELD* metadata, bool ownshipPassed= false);
ColumnDefinition(const MYSQL_FIELD* field, bool ownshipPassed= true);
ColumnDefinition& operator=(const ColumnDefinition& other);
Expand Down
2 changes: 2 additions & 0 deletions driver/class/Parameter.cpp
Expand Up @@ -17,6 +17,8 @@
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/

#include <cstring>

#include "Parameter.h"
#include "ColumnDefinition.h"

Expand Down
4 changes: 2 additions & 2 deletions driver/class/ResultSetText.h
Expand Up @@ -162,10 +162,10 @@ class ResultSetText : public ResultSet
bool getBoolean(int32_t index) const;
int8_t getByte(int32_t index) const;
int16_t getShort(int32_t index) const;
long double ResultSetText::getDouble(int32_t columnIndex) const;
long double getDouble(int32_t columnIndex) const;

ResultSetMetaData* getMetaData() const;
PreparedStatement* ResultSetText::getStatement();
PreparedStatement* getStatement();
/*Blob* getBlob(int32_t columnIndex) const;*/

std::size_t rowsCount() const;
Expand Down
12 changes: 6 additions & 6 deletions driver/class/TextRow.cpp
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2022 MariaDB Corporation AB
Copyright (C) 2022,2023 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace mariadb
if (date.empty() || date.compare(nullDate) == 0) {
if ((lastValueNull & BIT_LAST_ZERO_DATE) != 0) {
lastValueNull^= BIT_LAST_ZERO_DATE;
return SQLString(fieldBuf, length);
return SQLString(fieldBuf.arr, length);
}
return emptyStr;
}
Expand All @@ -115,7 +115,7 @@ namespace mariadb
if (timestamp.length() == 0) {
if ((lastValueNull & BIT_LAST_ZERO_DATE) != 0) {
lastValueNull^= BIT_LAST_ZERO_DATE;
return SQLString(fieldBuf, length);
return SQLString(fieldBuf.arr, length);
}
return emptyStr;
}
Expand All @@ -132,7 +132,7 @@ namespace mariadb
break;
}

return SQLString(fieldBuf, getLengthMaxFieldSize());
return SQLString(fieldBuf.arr, getLengthMaxFieldSize());
}


Expand Down Expand Up @@ -709,8 +709,8 @@ namespace mariadb
int32_t TextRow::fetchNext()
{
//Assuming it is called only for the case of the data from server, and not constructed text results
rowData= mysql_fetch_row(capiResults.get());
lengthArr= mysql_fetch_lengths(capiResults.get());
rowData= mysql_fetch_row(this->capiResults.get());
lengthArr= mysql_fetch_lengths(this->capiResults.get());

return 1;
}
Expand Down
2 changes: 2 additions & 0 deletions driver/class/TextRow.h
Expand Up @@ -21,6 +21,8 @@
#ifndef _TEXTROW_H_
#define _TEXTROW_H_

#include <memory>

#include "Row.h"
#include "mysql.h"

Expand Down
2 changes: 1 addition & 1 deletion driver/interface/Exception.h
Expand Up @@ -22,7 +22,7 @@
#define _EXCEPTION_H_

#include <stdexcept>
#include "SQLString.h"
#include "class/SQLString.h"

namespace odbc
{
Expand Down
3 changes: 2 additions & 1 deletion driver/interface/Row.h
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2022 MariaDB Corporation AB
Copyright (C) 2022,2023 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
Expand All @@ -23,6 +23,7 @@

#include <sstream>
#include <vector>
#include <memory>

#include "mysql.h"

Expand Down
25 changes: 24 additions & 1 deletion driver/ma_c_stuff.h
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2019,2022 MariaDB Corporation AB
Copyright (C) 2019,2023 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
Expand All @@ -19,6 +19,29 @@
#ifndef _ma_c_stuff_h_
#define _ma_c_stuff_h_

#include "ma_odbc_version.h"

#ifdef _WIN32
# include "ma_platform_win32.h"
#else
# include "ma_platform_posix.h"
#endif

#include <stdlib.h>

#include <ma_legacy_helpers.h>

#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>

#include <errmsg.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stddef.h>
#include <assert.h>
#include <time.h>
#include <sqlext.h>
#include <mysql.h>
#define MADB_FREE(a) do { \
Expand Down
2 changes: 1 addition & 1 deletion driver/ma_common.c
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2016 MariaDB Corporation AB
Copyright (C) 2016,2023 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
Expand Down
2 changes: 1 addition & 1 deletion driver/ma_connection.cpp
Expand Up @@ -1487,7 +1487,7 @@ SQLRETURN MADB_DbcGetInfo(MADB_Dbc *Dbc, SQLUSMALLINT InfoType, SQLPOINTER InfoV
break;
case SQL_DRIVER_ODBC_VER:
{
char *OdbcVersion = "03.51";
const char *OdbcVersion = "03.51";
/* DM requests this info before Dbc->Charset initialized. Thus checking if it is, and use utf8 by default
The other way would be to use utf8 when Dbc initialized */
SLen= (SQLSMALLINT)MADB_SetString(isWChar ? (Dbc->Charset.cs_info ? &Dbc->Charset : &utf8 ): NULL,
Expand Down
1 change: 1 addition & 0 deletions driver/ma_dsn.c
Expand Up @@ -19,6 +19,7 @@
#define _GNU_SOURCE
#include "ma_dsn.h"
#include "stdio.h"
#include "stddef.h"

#define DSNKEY_OPTIONS_INDEX 3
#define DSNKEY_OPTION_INDEX 4
Expand Down
9 changes: 0 additions & 9 deletions driver/ma_dsn.h
Expand Up @@ -19,15 +19,6 @@
#ifndef _ma_dsn_h_
#define _ma_dsn_h_

#ifdef _WIN32
# include "ma_platform_win32.h"
#else
# include "ma_platform_posix.h"
#endif
#include <odbcinst.h>
#include <sql.h>
#include <mysql.h>

#include "ma_c_stuff.h"

/* MySQL ODBC compatibility options */
Expand Down
2 changes: 1 addition & 1 deletion driver/ma_error.cpp
Expand Up @@ -405,7 +405,7 @@ SQLRETURN MADB_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
break;
case SQL_DIAG_SERVER_NAME:
{
char *ServerName= "";
const char *ServerName= "";
if (Stmt && Stmt->stmt)
{
mariadb_get_infov(Stmt->Connection->mariadb, MARIADB_CONNECTION_HOST, (void*)&ServerName);
Expand Down
10 changes: 5 additions & 5 deletions driver/ma_info.h
Expand Up @@ -21,19 +21,19 @@

typedef struct
{
char *TypeName;
const char *TypeName;
SQLSMALLINT DataType;
SQLINTEGER ColumnSize;
char *LiteralPrefix;
char *LiteralSuffix;
char *CreateParams;
const char *LiteralPrefix;
const char *LiteralSuffix;
const char *CreateParams;
SQLSMALLINT Nullable;
SQLSMALLINT CaseSensitive;
SQLSMALLINT Searchable;
SQLSMALLINT Unsigned;
SQLSMALLINT FixedPrecScale;
SQLSMALLINT AutoUniqueValue;
char *LocalTypeName;
const char *LocalTypeName;
SQLSMALLINT MinimumScale;
SQLSMALLINT MaximumScale;
SQLSMALLINT SqlDataType1;
Expand Down
40 changes: 7 additions & 33 deletions driver/ma_odbc.h
Expand Up @@ -19,32 +19,6 @@
#ifndef _ma_odbc_h_
#define _ma_odbc_h_

#include "ma_odbc_version.h"

#ifdef _WIN32
# include "ma_platform_win32.h"
#else
# include "ma_platform_posix.h"
#endif

#include <stdlib.h>

#include <mysql.h>

#include <ma_legacy_helpers.h>

#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>

#include <errmsg.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stddef.h>
#include <assert.h>
#include <time.h>

#include "class/SQLString.h"
#include "template/CArray.h"

Expand Down Expand Up @@ -146,8 +120,8 @@ typedef struct {
char* Label;
char* SchemaName;
char* TableName;
char* LiteralPrefix;
char* LiteralSuffix;
const char* LiteralPrefix;
const char* LiteralSuffix;
char* LocalTypeName;
char* TypeName;
char* InternalBuffer; /* used for internal conversion */
Expand Down Expand Up @@ -272,6 +246,11 @@ typedef struct

#define STMT_STRING(STMT) (STMT)->Query.Original

enum MADB_AppType {
ATypeGeneral= 0,
ATypeMSAccess= 1
};

typedef struct st_ma_odbc_environment {
MADB_Error Error;
CRITICAL_SECTION cs;
Expand Down Expand Up @@ -393,11 +372,6 @@ struct MADB_Stmt
MADB_Stmt()= delete;
};

enum MADB_AppType{
ATypeGeneral= 0,
ATypeMSAccess= 1
};

typedef BOOL (__stdcall *PromptDSN)(HWND hwnd, MADB_Dsn *Dsn);

typedef struct
Expand Down
3 changes: 2 additions & 1 deletion driver/ma_parse.h
Expand Up @@ -22,7 +22,8 @@
#include <vector>
#include <array>
#include <sqlext.h>
#include "SQLString.h"

#include "class/SQLString.h"

enum enum_madb_query_type { MADB_QUERY_NO_RESULT= 0, /* Default type for the query types we are not interested in */
MADB_QUERY_INSERT,
Expand Down
9 changes: 5 additions & 4 deletions driver/ma_string.cpp
Expand Up @@ -428,13 +428,15 @@ char *MADB_GetInsertStatement(MADB_Stmt *Stmt)
char *TableName;
uint32_t i, colCount;

if (!(TableName= MADB_GetTableName(Stmt)))
{
return nullptr;
}
if (!(StmtStr= static_cast<char*>(MADB_CALLOC(1024))))
{
MADB_SetError(&Stmt->Error, MADB_ERR_HY013, nullptr, 0);
return nullptr;
}
if (!(TableName= MADB_GetTableName(Stmt)))
goto error;
p= StmtStr;
p+= _snprintf(StmtStr, 1024, "INSERT INTO `%s` (", TableName);

Expand Down Expand Up @@ -474,8 +476,7 @@ char *MADB_GetInsertStatement(MADB_Stmt *Stmt)
return StmtStr;

error:
if (StmtStr)
MADB_FREE(StmtStr);
MADB_FREE(StmtStr);
return nullptr;
}

Expand Down

0 comments on commit b72749f

Please sign in to comment.