KiCad PCB EDA Suite
Loading...
Searching...
No Matches
odbc_backend.cpp File Reference
#include "odbc_backend.h"
#include "access_engine_mutex.h"
#include "db_worker_thread.h"
#include <algorithm>
#include <charconv>
#include <mutex>
#include <regex>
#include <boost/algorithm/string.hpp>
#include <boost/locale.hpp>
#include <fmt/format.h>
#include <nanodbc/nanodbc.h>
#include <sql.h>
#include <sqlext.h>
#include <wx/log.h>
#include <database/access_fast_exit.h>
#include <database/database_value.h>
#include <core/profile.h>

Go to the source code of this file.

Classes

struct  RESULT_COLUMN
 

Functions

static nanodbc::string fromUTF8 (const std::string &aString)
 When Unicode support is enabled in nanodbc, string formats are used matching the appropriate character set of the platform.
 
static std::string toUTF8 (const nanodbc::string &aString)
 Converts a string from nanodbc-native to KiCad-native.
 
static std::vector< RESULT_COLUMN > resultColumns (nanodbc::result &aResults)
 Column names and types are the same for every row, so read them once per result set.
 
static std::vector< DB_VALUE > decodeRow (nanodbc::result &aResults, const std::vector< RESULT_COLUMN > &aColumns)
 Decodes the current row of a result set into values in column order.
 

Variables

static constexpr unsigned long DEFAULT_KEY_CHAR_SIZE = 255
 
static constexpr unsigned long MAX_KEY_CHAR_SIZE = 8000
 
static constexpr unsigned long DEFAULT_KEY_INTEGER_SIZE = 19
 
static constexpr unsigned long DEFAULT_KEY_DECIMAL_SIZE = 38
 

Function Documentation

◆ decodeRow()

static std::vector< DB_VALUE > decodeRow ( nanodbc::result & aResults,
const std::vector< RESULT_COLUMN > & aColumns )
static

Decodes the current row of a result set into values in column order.

Floating-point columns keep their full precision, exact numerics are trimmed decimal text and nulls become empty strings.

Definition at line 102 of file odbc_backend.cpp.

References NormalizeDecimalText(), and toUTF8().

Referenced by ODBC_BACKEND::ReadRow(), and ODBC_BACKEND::ReadTable().

◆ fromUTF8()

static nanodbc::string fromUTF8 ( const std::string & aString)
static

When Unicode support is enabled in nanodbc, string formats are used matching the appropriate character set of the platform.

KiCad uses UTF-8 encoded strings internally, but different platforms use different encodings for SQL strings. Unicode mode must be enabled for compilation on Windows, since Visual Studio forces the use of Unicode SQL headers if any part of the project has Unicode enabled. Converts a string from KiCad-native to nanodbc-native

Parameters
aStringis a UTF-8 encoded string
Returns
a string in nanodbc's platform-specific representation

Definition at line 61 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::Connect(), ODBC_BACKEND::DescribeTable(), ODBC_BACKEND::ListColumns(), ODBC_BACKEND::ListTables(), ODBC_BACKEND::ReadRow(), and ODBC_BACKEND::ReadTable().

◆ resultColumns()

static std::vector< RESULT_COLUMN > resultColumns ( nanodbc::result & aResults)
static

Column names and types are the same for every row, so read them once per result set.

Definition at line 86 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::ReadRow(), and ODBC_BACKEND::ReadTable().

◆ toUTF8()

static std::string toUTF8 ( const nanodbc::string & aString)
static

Converts a string from nanodbc-native to KiCad-native.

Parameters
aStringis a string encoded in nanodbc's platform-specific way
Returns
a string with UTF-8 encoding

Definition at line 72 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::Connect(), decodeRow(), ODBC_BACKEND::DescribeTable(), ODBC_BACKEND::getQuoteChar(), ODBC_BACKEND::ListColumns(), ODBC_BACKEND::ListDataSourceDetails(), ODBC_BACKEND::ListDrivers(), ODBC_BACKEND::ListTables(), and ODBC_BACKEND::ReadRow().

Variable Documentation

◆ DEFAULT_KEY_CHAR_SIZE

unsigned long DEFAULT_KEY_CHAR_SIZE = 255
staticconstexpr

Definition at line 620 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::DescribeKeyParameter().

◆ DEFAULT_KEY_DECIMAL_SIZE

unsigned long DEFAULT_KEY_DECIMAL_SIZE = 38
staticconstexpr

Definition at line 623 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::DescribeKeyParameter().

◆ DEFAULT_KEY_INTEGER_SIZE

unsigned long DEFAULT_KEY_INTEGER_SIZE = 19
staticconstexpr

Definition at line 622 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::DescribeKeyParameter().

◆ MAX_KEY_CHAR_SIZE

unsigned long MAX_KEY_CHAR_SIZE = 8000
staticconstexpr

Definition at line 621 of file odbc_backend.cpp.

Referenced by ODBC_BACKEND::DescribeKeyParameter().