Support for new 'Connection.FullVersion' property in database drivers. Tells if 'RETURNING' keyword is implemented.
[GB.DB.MYSQL] * NEW: Support for new 'Connection.FullVersion' property. * NEW: Tells if 'RETURNING' keyword is implemented. [GB.DB.ODBC] * NEW: Support for new 'Connection.FullVersion' property. * NEW: Tells if 'RETURNING' keyword is implemented. [GB.DB.POSTGRESQL] * NEW: Support for new 'Connection.FullVersion' property. * NEW: Tells if 'RETURNING' keyword is implemented. [GB.DB.SQLITE2] * NEW: Support for new 'Connection.FullVersion' property. * NEW: Tells if 'RETURNING' keyword is implemented. [GB.DB.SQLITE3] * NEW: Support for new 'Connection.FullVersion' property. * NEW: Tells if 'RETURNING' keyword is implemented.
This commit is contained in:
parent
257bd622a3
commit
72971105ef
@ -591,25 +591,26 @@ static int do_query_cached(DB_DATABASE *db, const char *error, MYSQL_RES **pres,
|
||||
}
|
||||
|
||||
|
||||
/* Internal function to return database version number as a XXYYZZ integer number*/
|
||||
// Internal function to get database version
|
||||
|
||||
static int db_version(DB_DATABASE *db)
|
||||
static void init_version(DB_DATABASE *db)
|
||||
{
|
||||
//Check db version
|
||||
const char *vquery = "select left(version(),6)";
|
||||
long dbversion =0;
|
||||
const char *query = "select version()";
|
||||
char *version;
|
||||
uint verMain, verMajor, verMinor;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (!do_query(db, NULL, &res, vquery, 0))
|
||||
if (!do_query(db, NULL, &res, query, 0))
|
||||
{
|
||||
unsigned int verMain, verMajor, verMinor;
|
||||
row = mysql_fetch_row(res);
|
||||
sscanf(row[0],"%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
dbversion = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
version = mysql_fetch_row(res)[0];
|
||||
|
||||
db->full_version = GB.NewZeroString(version);
|
||||
|
||||
sscanf(version, "%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
db->version = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
|
||||
mysql_free_result(res);
|
||||
}
|
||||
return dbversion;
|
||||
}
|
||||
|
||||
/* Search in the first column a result for a specific name */
|
||||
@ -975,7 +976,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
}
|
||||
|
||||
db->handle = conn;
|
||||
db->version = db_version(db);
|
||||
init_version(db);
|
||||
|
||||
set_character_set(db);
|
||||
|
||||
|
@ -858,7 +858,9 @@ fflush(stderr);
|
||||
odbc->user_name = malloc(sizeof(char) * strlen(user));
|
||||
strcpy(odbc->user_name, user);
|
||||
|
||||
// TODO: Use SQLGetInfo() to retrieve the DBMS version string
|
||||
db->version = 3;
|
||||
db->full_version = GB.NewZeroString("3");
|
||||
|
||||
retcode = SQLGetFunctions(odbc->odbcHandle, SQL_API_SQLFETCHSCROLL, &odbc->drvrCanFetchScroll);
|
||||
if (!SQL_SUCCEEDED(retcode))
|
||||
|
@ -544,14 +544,13 @@ static int do_query(DB_DATABASE *db, const char *error, PGresult **pres, const c
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Internal function to check database version number */
|
||||
// Internal function to get database version
|
||||
|
||||
static int db_version(DB_DATABASE *db)
|
||||
static void init_version(DB_DATABASE *db)
|
||||
{
|
||||
unsigned int verMain = 0, verMajor = 0, verMinor = 0;
|
||||
const char *query = "select version()";
|
||||
const char *version;
|
||||
int dbversion = 0;
|
||||
PGresult *res;
|
||||
|
||||
if (!do_query(db, NULL, &res, query, 0))
|
||||
@ -563,14 +562,14 @@ static int db_version(DB_DATABASE *db)
|
||||
|
||||
if (*version)
|
||||
{
|
||||
db->full_version = GB.NewZeroString(version);
|
||||
|
||||
sscanf(version, "%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
dbversion = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
db->version = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
return dbversion;
|
||||
}
|
||||
|
||||
/* Internal function that fills field information from a schema request.
|
||||
@ -785,7 +784,9 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
/* get version */
|
||||
|
||||
db->handle = conn;
|
||||
db->version = db_version(db);
|
||||
|
||||
init_version(db);
|
||||
|
||||
db->data = (void *)0; // transaction level
|
||||
|
||||
if (db->version >= 90000)
|
||||
@ -817,6 +818,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
//db->flags.no_case = TRUE;
|
||||
db->flags.schema = TRUE;
|
||||
db->flags.no_collation = db->version < 90100;
|
||||
db->flags.no_returning = db->version < 80200; // It seems that RETURNING has been introduced in PostgreSQL 8.2
|
||||
|
||||
/* encoding */
|
||||
|
||||
|
@ -484,17 +484,22 @@ static int WalkDirectory(const char *dir, char ***databases)
|
||||
return GB.Count(databases);
|
||||
}
|
||||
|
||||
/* Internal function to check database version number */
|
||||
int db_version()
|
||||
// Internal function to get database version
|
||||
|
||||
static int init_version(DB_DATABASE *db)
|
||||
{
|
||||
//Check db version
|
||||
char *version;
|
||||
int dbversion = 0;
|
||||
unsigned int verMain, verMajor, verMinor;
|
||||
sscanf(sqlite_version,"%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
dbversion = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
return dbversion;
|
||||
|
||||
version = sqlite3_libversion();
|
||||
db->full_version = GB.NewZeroString(version);
|
||||
|
||||
sscanf(version, "%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
db->version = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
get_quote()
|
||||
@ -581,7 +586,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
db->charset = GB.NewZeroString(strcmp(sqlite_encoding, "iso8859") == 0 ? "ISO-8859-1" : "UTF-8");
|
||||
|
||||
/* set dbversion */
|
||||
db->version = db_version();
|
||||
init_version(db);
|
||||
|
||||
/* flags */
|
||||
db->flags.no_table_type = TRUE;
|
||||
@ -589,6 +594,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
db->flags.no_blob = TRUE;
|
||||
db->flags.no_nest = TRUE;
|
||||
db->flags.no_collation = TRUE;
|
||||
db->flags.no_returning = TRUE;
|
||||
|
||||
db->db_name_char = ".";
|
||||
|
||||
|
@ -500,19 +500,22 @@ static int walk_directory(const char *dir, char ***databases)
|
||||
}
|
||||
|
||||
|
||||
/* Internal function to check database version number */
|
||||
static int db_version()
|
||||
// Internal function to get database version
|
||||
|
||||
static void init_version(DB_DATABASE *db)
|
||||
{
|
||||
//Check db version
|
||||
int dbversion = 0;
|
||||
const char *version;
|
||||
unsigned int verMain, verMajor, verMinor;
|
||||
|
||||
sscanf(sqlite3_libversion(), "%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
dbversion = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
return dbversion;
|
||||
version = sqlite3_libversion();
|
||||
db->full_version = GB.NewZeroString(version);
|
||||
|
||||
sscanf(version, "%2u.%2u.%2u", &verMain, &verMajor, &verMinor);
|
||||
db->version = ((verMain * 10000) + (verMajor * 100) + verMinor);
|
||||
}
|
||||
|
||||
/* Get the schema of a table */
|
||||
// Get the schema of a table
|
||||
|
||||
static char *get_table_schema(DB_DATABASE *db, const char *table)
|
||||
{
|
||||
char *schema = NULL;
|
||||
@ -598,8 +601,8 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
}
|
||||
|
||||
db->handle = conn;
|
||||
/* set dbversion */
|
||||
db->version = db_version();
|
||||
|
||||
init_version(db);
|
||||
|
||||
if (do_query(db, "Unable to initialize connection: &1", NULL, "PRAGMA empty_result_callbacks = ON", 0))
|
||||
goto CANNOT_OPEN;
|
||||
@ -623,6 +626,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
||||
/* flags */
|
||||
db->flags.no_table_type = TRUE;
|
||||
db->flags.no_nest = TRUE;
|
||||
db->flags.no_returning = TRUE; //db->version < 33500; // RETURNING keyword has been introduced in SQLite 3.35.0
|
||||
|
||||
db->db_name_char = ".";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user