summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-11-13 10:36:32 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-11-13 10:36:32 +0100
commit68f70a6fef58b8b13ab7b922272c687589953173 (patch)
tree1039ccefbd1221b0e8e2bd848516870dd60f1426 /database/sqlite
parent8a3c00f570f512a898bc6dc33bf64c95ee1283b4 (diff)
parenta2fe09750428ca71b14ab1f85bcd26b0ffb2811a (diff)
Merge commit 'origin/next' into next
Diffstat (limited to 'database/sqlite')
-rw-r--r--database/sqlite/administration/attempts.c2
-rw-r--r--database/sqlite/administration/blacklist.c2
-rw-r--r--database/sqlite/administration/certificates.c3
-rw-r--r--database/sqlite/administration/firewalladmin.c2
-rw-r--r--database/sqlite/administration/lastlog.c2
-rw-r--r--database/sqlite/administration/useraccount.c4
-rw-r--r--database/sqlite/administration/usercerts.c2
-rw-r--r--database/sqlite/edb-sqlite.c39
-rw-r--r--database/sqlite/fieldmapping.h62
-rw-r--r--database/sqlite/sqlite.c24
10 files changed, 79 insertions, 63 deletions
diff --git a/database/sqlite/administration/attempts.c b/database/sqlite/administration/attempts.c
index e94878a..b35b386 100644
--- a/database/sqlite/administration/attempts.c
+++ b/database/sqlite/administration/attempts.c
@@ -74,7 +74,7 @@ xmlDoc *attempts_list(eurephiaCTX *ctx, eDBfieldMap *fmap) {
// Query the database for registered attempts
res = sqlite_query_mapped(ctx, SQL_SELECT,
- "SELECT username, digest, remoteip, attempts,"
+ "SELECT username, lower(digest), remoteip, attempts,"
" registered, last_attempt, atpid"
" FROM openvpn_attempts",
NULL, fmap, "atpid");
diff --git a/database/sqlite/administration/blacklist.c b/database/sqlite/administration/blacklist.c
index 80c4506..79f4b87 100644
--- a/database/sqlite/administration/blacklist.c
+++ b/database/sqlite/administration/blacklist.c
@@ -75,7 +75,7 @@ xmlDoc *blacklist_list(eurephiaCTX *ctx, eDBfieldMap *fmap) {
// Query the database for registered attempts
res = sqlite_query_mapped(ctx, SQL_SELECT,
- "SELECT username, digest, remoteip,"
+ "SELECT username, lower(digest), remoteip,"
" registered, last_accessed, blid"
" FROM openvpn_blacklist",
NULL, fmap, "blid");
diff --git a/database/sqlite/administration/certificates.c b/database/sqlite/administration/certificates.c
index b64aa07..d8b7a23 100644
--- a/database/sqlite/administration/certificates.c
+++ b/database/sqlite/administration/certificates.c
@@ -86,7 +86,8 @@ static xmlDoc *certificate_list(eurephiaCTX *ctx, eDBfieldMap *srch_map, const c
}
res = sqlite_query_mapped(ctx, SQL_SELECT,
- "SELECT depth, digest, common_name, organisation, email, registered, certid"
+ "SELECT depth, lower(digest), common_name, organisation, email, "
+ " registered, certid"
" FROM openvpn_certificates", NULL, srch_map, sortkeys);
if( res == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Could not query the certificate table");
diff --git a/database/sqlite/administration/firewalladmin.c b/database/sqlite/administration/firewalladmin.c
index fdebccb..3ea2f28 100644
--- a/database/sqlite/administration/firewalladmin.c
+++ b/database/sqlite/administration/firewalladmin.c
@@ -89,7 +89,7 @@ xmlDoc *fwadmin_search(eurephiaCTX *ctx, eDBfieldMap *fmap) {
"SELECT access_descr, fw_profile, accessprofile, "
" uid, username, "
" uac.certid, common_name, organisation, "
- " email, digest, c.registered, uicid "
+ " email, lower(digest), c.registered, uicid "
" FROM openvpn_accesses"
" LEFT JOIN openvpn_usercerts uac USING (accessprofile)"
" LEFT JOIN openvpn_users USING (uid)"
diff --git a/database/sqlite/administration/lastlog.c b/database/sqlite/administration/lastlog.c
index e850d94..64adf78 100644
--- a/database/sqlite/administration/lastlog.c
+++ b/database/sqlite/administration/lastlog.c
@@ -96,7 +96,7 @@ xmlDoc *eDBadminGetLastlog(eurephiaCTX *ctx, xmlDoc *srch_xml, const char *sortk
" vpnipaddr, vpnipmask, sessionstatus, sessionkey,"
" login, logout, session_duration, session_deleted,"
" bytes_sent, bytes_received, uicid, accessprofile,"
- " access_descr, fw_profile, depth, digest,"
+ " access_descr, fw_profile, depth, lower(digest),"
" common_name, organisation, email, username, ll.uid"
" FROM openvpn_lastlog ll"
" LEFT JOIN openvpn_usercerts USING (uid, certid)"
diff --git a/database/sqlite/administration/useraccount.c b/database/sqlite/administration/useraccount.c
index 17b9330..3c2c5d3 100644
--- a/database/sqlite/administration/useraccount.c
+++ b/database/sqlite/administration/useraccount.c
@@ -177,7 +177,7 @@ static xmlDoc *useracc_view(eurephiaCTX *ctx, unsigned int infoType,
if( infoType & USERINFO_certs ) {
// Extract certificate info
qres = sqlite_query(ctx,
- "SELECT depth, digest, common_name, organisation, email, "
+ "SELECT depth, lower(digest), common_name, organisation, email, "
" c.registered, c.certid, uc.accessprofile, access_descr,"
" fw_profile"
" FROM openvpn_certificates c"
@@ -230,7 +230,7 @@ static xmlDoc *useracc_view(eurephiaCTX *ctx, unsigned int infoType,
" vpnipaddr, vpnipmask, sessionstatus, sessionkey,"
" login, logout, session_duration, session_deleted,"
" bytes_sent, bytes_received, uicid, accessprofile,"
- " access_descr, fw_profile, depth, digest,"
+ " access_descr, fw_profile, depth, lower(digest),"
" common_name, organisation, email"
" FROM openvpn_lastlog ll"
" LEFT JOIN openvpn_usercerts USING (uid, certid)"
diff --git a/database/sqlite/administration/usercerts.c b/database/sqlite/administration/usercerts.c
index 8e235c5..abc0b40 100644
--- a/database/sqlite/administration/usercerts.c
+++ b/database/sqlite/administration/usercerts.c
@@ -92,7 +92,7 @@ xmlDoc *usercerts_search(eurephiaCTX *ctx, eDBfieldMap *where_m, const char *sor
"SELECT uicid, ucs.uid AS uid, certid, ucs.registered AS registered,"
" ucs.accessprofile AS accessprofile, access_descr,"
" username, "
- " common_name, organisation, email, digest, depth "
+ " common_name, organisation, email, lower(digest), depth "
" FROM openvpn_usercerts ucs"
" LEFT JOIN openvpn_certificates USING(certid)"
" LEFT JOIN openvpn_accesses acc ON(ucs.accessprofile = acc.accessprofile)"
diff --git a/database/sqlite/edb-sqlite.c b/database/sqlite/edb-sqlite.c
index 6728f84..b9a311b 100644
--- a/database/sqlite/edb-sqlite.c
+++ b/database/sqlite/edb-sqlite.c
@@ -1,5 +1,5 @@
-/* eurephia-sqlite.c -- Main driver for eurephia authentication plugin for OpenVPN
- * This is the SQLite database driver
+/* edb-sqlite.c -- Main driver for eurephia authentication plugin for OpenVPN
+ * This is the SQLite database driver
*
* GPLv2 only - Copyright (C) 2008, 2009
* David Sommerseth <dazo@users.sourceforge.net>
@@ -61,10 +61,11 @@
* to database field names, configuration options (with default values) and description
*/
typedef struct {
- char *colname; /**< Column name when doing look up in blacklist and attempts tables */
- char *allow_cfg; /**< Configure parameter for the attempt limits */
- char *descr; /**< Description, used to give more readable output for users */
- char *default_value; /**< Default value, if config option is not found */
+ char *colname; /**< Column name when doing look up in blacklist and attempts tables */
+ char *allow_cfg; /**< Configure parameter for the attempt limits */
+ char *descr; /**< Description, used to give more readable output for users */
+ char *default_value; /**< Default value, if config option is not found */
+ char *value_func; /**< If not NULL, the value will be passed through the given SQL function */
} eDBattempt_types_t;
@@ -72,11 +73,11 @@ typedef struct {
* Static mapping table with the needed values. Uses the eDBattempt_types_t struct.
*/
static const eDBattempt_types_t eDBattempt_types[] = {
- {NULL, NULL, NULL},
- {"remoteip\0", "allow_ipaddr_attempts\0", "IP Address\0", "10\0"},
- {"digest\0", "allow_cert_attempts\0", "Certificate\0", "5\0"},
- {"username\0", "allow_username_attempts\0", "Username\0", "5\0"},
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL, NULL},
+ {"remoteip\0", "allow_ipaddr_attempts\0", "IP Address\0", "10\0", NULL},
+ {"lower(digest)\0", "allow_cert_attempts\0", "Certificate\0", "5\0", "lower\0"},
+ {"username\0", "allow_username_attempts\0", "Username\0", "5\0", NULL},
+ {NULL, NULL, NULL, NULL}
};
@@ -232,7 +233,7 @@ int eDBauth_TLS(eurephiaCTX *ctx, const char *org, const char *cname, const char
" FROM openvpn_certificates cert"
" LEFT JOIN openvpn_blacklist bl USING(digest)"
" WHERE organisation='%q' AND common_name='%q' "
- " AND email='%q' AND depth='%i' AND cert.digest='%q'%c",
+ " AND email='%q' AND depth='%i' AND lower(cert.digest)=lower('%q')%c",
org, cname, email, depth, digest, 0);
if( res != NULL ) {
@@ -253,7 +254,7 @@ int eDBauth_TLS(eurephiaCTX *ctx, const char *org, const char *cname, const char
eurephia_log(ctx, LOG_FATAL, 0, "Could not look up certificate information");
}
- DEBUG(ctx, 20, "Result function call: eDBauth_TLS(ctx, '%s', '%s', '%s', '%s', %s) - %i",
+ DEBUG(ctx, 20, "Result function call: eDBauth_TLS(ctx, '%s', '%s', '%s', '%s', %i) - %i",
org, cname, email, digest, depth, certid);
return certid;
@@ -405,8 +406,12 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
DEBUG(ctx, 20, "Function call: eDBblacklist_check(ctx, '%s', '%s')",
eDBattempt_types[type].descr, val);
- blr = sqlite_query(ctx, "SELECT blid FROM openvpn_blacklist WHERE %s = '%q'",
- eDBattempt_types[type].colname, val);
+ blr = sqlite_query(ctx, "SELECT blid FROM openvpn_blacklist WHERE %s = %s%s'%q'%s",
+ eDBattempt_types[type].colname,
+ defaultValue(eDBattempt_types[type].value_func, ""),
+ (strlen_nullsafe(eDBattempt_types[type].value_func) > 0 ? "(" : ""),
+ val,
+ (strlen_nullsafe(eDBattempt_types[type].value_func) > 0 ? ")" : ""));
if( blr != NULL ) {
blid = strdup_nullsafe(sqlite_get_value(blr, 0, 0));
sqlite_free_results(blr);
@@ -1033,8 +1038,8 @@ eurephiaVALUES *eDBget_blacklisted_ip(eurephiaCTX *ctx) {
if( res == NULL ) {
eurephia_log(ctx, LOG_FATAL, 0,
"Could not retrieve blacklisted IP addresses from the database");
- return NULL;
- }
+ return NULL;
+ }
ret = eCreate_value_space(ctx, 21);
for( i = 0; i < sqlite_get_numtuples(res); i++ ) {
if( (ip = sqlite_get_value(res, i, 0)) != NULL ) {
diff --git a/database/sqlite/fieldmapping.h b/database/sqlite/fieldmapping.h
index 7d156fb..b4b8336 100644
--- a/database/sqlite/fieldmapping.h
+++ b/database/sqlite/fieldmapping.h
@@ -48,13 +48,13 @@ static eDBfieldMap tbl_sqlite_users[] = {
#ifdef FMAP_CERTS
static eDBfieldMap tbl_sqlite_certs[] = {
- {TABLE_CERTS, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "certid", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_CERTDEPTH, ft_INT , flt_NOTSET, "depth", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_CERTDIGEST, ft_STRING , flt_NOTSET, "digest", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_CNAME, ft_STRING , flt_NOTSET, "common_name", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_ORG, ft_STRING , flt_NOTSET, "organisation", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_EMAIL, ft_STRING , flt_NOTSET, "email", NULL, NULL},
- {TABLE_CERTS, NULL, FIELD_REGISTERED, ft_DATETIME, flt_NOTSET, "registered", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "certid", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_CERTDEPTH, ft_INT , flt_NOTSET, "depth", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_CERTDIGEST, ft_STRING_LOWER, flt_NOTSET, "digest", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_CNAME, ft_STRING , flt_NOTSET, "common_name", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_ORG, ft_STRING , flt_NOTSET, "organisation", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_EMAIL, ft_STRING , flt_NOTSET, "email", NULL, NULL},
+ {TABLE_CERTS, NULL, FIELD_REGISTERED, ft_DATETIME , flt_NOTSET, "registered", NULL, NULL},
{0, NULL, FIELD_NONE, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
#endif
@@ -98,42 +98,42 @@ static eDBfieldMap tbl_sqlite_lastlog[] = {
#ifdef FMAP_OVPNACCESSES
static eDBfieldMap tbl_sqlite_openvpnaccesses[] = {
- {TABLE_FWPROFILES, NULL, FIELD_DESCR, ft_STRING , flt_NOTSET, "access_descr", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_FWPROFILE, ft_STRING , flt_NOTSET, "fw_profile", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "accessprofile", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_UID, ft_INT , flt_NOTSET, "uid", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_UNAME, ft_STRING , flt_NOTSET, "username", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_CERTID, ft_INT , flt_NOTSET, "certid", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_CNAME, ft_STRING , flt_NOTSET, "common_name", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_ORG, ft_STRING , flt_NOTSET, "organisation", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_EMAIL, ft_STRING , flt_NOTSET, "email", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_CERTDIGEST, ft_STRING , flt_NOTSET, "digest", NULL, NULL},
- {TABLE_FWPROFILES, NULL, FIELD_REGISTERED, ft_DATETIME, flt_NOTSET, "registered", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_DESCR, ft_STRING , flt_NOTSET, "access_descr", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_FWPROFILE, ft_STRING , flt_NOTSET, "fw_profile", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "accessprofile", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_UID, ft_INT , flt_NOTSET, "uid", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_UNAME, ft_STRING , flt_NOTSET, "username", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_CERTID, ft_INT , flt_NOTSET, "certid", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_CNAME, ft_STRING , flt_NOTSET, "common_name", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_ORG, ft_STRING , flt_NOTSET, "organisation", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_EMAIL, ft_STRING , flt_NOTSET, "email", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_CERTDIGEST, ft_STRING_LOWER, flt_NOTSET, "digest", NULL, NULL},
+ {TABLE_FWPROFILES, NULL, FIELD_REGISTERED, ft_DATETIME , flt_NOTSET, "registered", NULL, NULL},
{0, NULL, FIELD_NONE, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
#endif
#ifdef FMAP_OVPNATTEMPTS
static eDBfieldMap tbl_sqlite_attempts[] = {
- {TABLE_ATTEMPTS, NULL, FIELD_UNAME, ft_STRING, flt_NOTSET, "username", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_REMOTEIP, ft_STRING, flt_NOTSET, "remoteip", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_CERTDIGEST, ft_STRING, flt_NOTSET, "digest", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_ATTEMPTS, ft_INT, flt_NOTSET, "attempts", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_REGISTERED, ft_DATETIME, flt_NOTSET, "registered", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_LASTATTEMPT, ft_DATETIME, flt_NOTSET, "last_attempt", NULL, NULL},
- {TABLE_ATTEMPTS, NULL, FIELD_RECID, ft_INT, flt_NOTSET, "atpid", NULL, NULL },
+ {TABLE_ATTEMPTS, NULL, FIELD_UNAME, ft_STRING , flt_NOTSET, "username", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_REMOTEIP, ft_STRING , flt_NOTSET, "remoteip", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_CERTDIGEST, ft_STRING_LOWER, flt_NOTSET, "digest", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_ATTEMPTS, ft_INT , flt_NOTSET, "attempts", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_REGISTERED, ft_DATETIME , flt_NOTSET, "registered", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_LASTATTEMPT, ft_DATETIME , flt_NOTSET, "last_attempt", NULL, NULL},
+ {TABLE_ATTEMPTS, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "atpid", NULL, NULL },
{0, NULL, FIELD_NONE, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
#endif
#ifdef FMAP_OVPNBLACKLIST
static eDBfieldMap tbl_sqlite_blacklist[] = {
- {TABLE_BLACKLIST, NULL, FIELD_UNAME, ft_STRING, flt_NOTSET, "username", NULL, NULL},
- {TABLE_BLACKLIST, NULL, FIELD_REMOTEIP, ft_STRING, flt_NOTSET, "remoteip", NULL, NULL},
- {TABLE_BLACKLIST, NULL, FIELD_CERTDIGEST, ft_STRING, flt_NOTSET, "digest", NULL, NULL},
- {TABLE_BLACKLIST, NULL, FIELD_REGISTERED, ft_DATETIME, flt_NOTSET, "registered", NULL, NULL},
- {TABLE_BLACKLIST, NULL, FIELD_LASTACCESS, ft_DATETIME, flt_NOTSET, "last_accessed", NULL, NULL},
- {TABLE_BLACKLIST, NULL, FIELD_RECID, ft_INT, flt_NOTSET, "blid", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_UNAME, ft_STRING , flt_NOTSET, "username", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_REMOTEIP, ft_STRING , flt_NOTSET, "remoteip", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_CERTDIGEST, ft_STRING_LOWER, flt_NOTSET, "digest", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_REGISTERED, ft_DATETIME , flt_NOTSET, "registered", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_LASTACCESS, ft_DATETIME , flt_NOTSET, "last_accessed", NULL, NULL},
+ {TABLE_BLACKLIST, NULL, FIELD_RECID, ft_INT , flt_NOTSET, "blid", NULL, NULL},
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
#endif
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c
index 6021462..13a6f07 100644
--- a/database/sqlite/sqlite.c
+++ b/database/sqlite/sqlite.c
@@ -270,10 +270,10 @@ dbresult *sqlite_query(eurephiaCTX *ctx, const char *fmt, ... ) {
if( strcasestr(sql, "INSERT INTO") != 0) {
dbres->last_insert_id = sqlite3_last_insert_rowid((sqlite3 *) dbc->dbhandle);
};
- if( strcasestr(sql, "SELECT ") == 0 ) {
- // If not a SELECT query, then get the number of affected records
- dbres->affected_rows = sqlite3_changes((sqlite3 *) dbc->dbhandle);
- }
+ if( strcasestr(sql, "SELECT ") == 0 ) {
+ // If not a SELECT query, then get the number of affected records
+ dbres->affected_rows = sqlite3_changes((sqlite3 *) dbc->dbhandle);
+ }
dbres->srch_tuples = dbres->tuples;
dbres->srch_headerrec = dbres->headerrec;
@@ -311,7 +311,7 @@ inline int SQLreservedWord(char **reserved_words, const char *val) {
*
* @return Returns a string to be used within an SQL query.
*/
-char *_build_value_string(eDBfieldMap *ptr) {
+static char *_build_value_string(eDBfieldMap *ptr) {
char *reserved_datetime[] = {"CURRENT_TIMESTAMP", "CURRENT_TIME", "CURRENT_DATE", NULL};
char *val = NULL;
@@ -335,6 +335,10 @@ char *_build_value_string(eDBfieldMap *ptr) {
val = sqlite3_mprintf("NULL");
break;
+ case ft_STRING_LOWER:
+ val = sqlite3_mprintf("lower('%q')", ptr->value);
+ break;
+
case ft_PASSWD:
case ft_STRING:
default:
@@ -355,7 +359,7 @@ char *_build_value_string(eDBfieldMap *ptr) {
* @return Returns a string with parts of the SQL query containing the dynamic variables on success,
* otherwise NULL is returned.
*/
-char *_build_sqlpart(int btyp, eDBfieldMap *map) {
+static char *_build_sqlpart(int btyp, eDBfieldMap *map) {
eDBfieldMap *ptr = NULL;
char *ret = NULL;
char *fsep = NULL;
@@ -393,7 +397,13 @@ char *_build_sqlpart(int btyp, eDBfieldMap *map) {
append_str(buf, ptr->table_alias, 8192);
append_str(buf, ".", 8192);
}
- append_str(buf, ptr->field_name, 8192);
+ if( (btyp == btWHERE) && ptr->field_type == ft_STRING_LOWER ) {
+ append_str(buf, "lower(", 8192);
+ append_str(buf, ptr->field_name, 8192);
+ append_str(buf, ")", 8192);
+ } else {
+ append_str(buf, ptr->field_name, 8192);
+ }
switch( ptr->filter_type ) {
case flt_LT: