[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi/kexidb/drivers/mySQL
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2006-02-02 0:05:41
Message-ID: 1138838741.391214.13429.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 504730 by staniek:
-possible crash fixed
-another fix for special characters
M +0 -62 mysqlconnection.cpp
M +0 -2 mysqlconnection.h
M +5 -4 mysqlcursor.cpp
M +7 -7 mysqldriver.cpp
--- trunk/koffice/kexi/kexidb/drivers/mySQL/mysqlconnection.cpp #504729:504730
@@ -65,16 +65,6 @@
return new MySqlCursor( this, query, cursor_options );
}
-QString MySqlConnection::escapeString(const QString& str) const {
- Q_UNUSED(str);
- return QString();//!< @todo
-}
-
-QCString MySqlConnection::escapeString(const QCString& str) const {
- Q_UNUSED(str);
- return QCString();//!< @todo
-}
-
bool MySqlConnection::drv_getDatabasesList( QStringList &list ) {
KexiDBDrvDbg << "MySqlConnection::drv_getDatabasesList()" << endl;
list.clear();
@@ -188,56 +178,4 @@
return new MySqlPreparedStatement(type, *d, tableSchema);
}
-
-#if 0 //old code
-
-QString
-MySqlDB::escape(const QString &str)
-{
-// QCString val(encode(str));
- char* escaped = (char*) malloc(str.length() * 2 + 2);
- mysql_real_escape_string(m_mysql, escaped, str.local8Bit(), str.length());
-
- QString rval = escaped;
- free(escaped);
- return rval;
-}
-
-QString
-KexiDBTableStruct
-MySqlDB::structure(const QString& table) const
-{
- KexiDBTableStruct dbStruct;
- MYSQL_RES* result= mysql_list_fields(m_mysql, table.local8Bit().data(), 0);
- KexiDBDrvDbg << "MySqlDB::structure: Get fields..." << endl;
-
- if(result)
- {
- MYSQL_FIELD* field;
-
- while((field = mysql_fetch_field(result)))
- {
- KexiDBField* f = new KexiDBField(field->table);
- f->setName(field->name);
- f->setColumnType(getInternalDataType(field->type));
- f->setLength(field->length);
- f->setPrecision(field->decimals);
- f->setUnsigned(field->flags & UNSIGNED_FLAG);
- f->setBinary(field->flags & BINARY_FLAG);
- f->setDefaultValue(field->def);
- f->setAutoIncrement(field->flags & AUTO_INCREMENT_FLAG);
- f->setPrimaryKey(field->flags & PRI_KEY_FLAG);
- f->setUniqueKey(field->flags & UNIQUE_KEY_FLAG);
- f->setNotNull(field->flags & NOT_NULL_FLAG);
- dbStruct.append(f);
- }
-
- mysql_free_result(result);
- }
-
- return dbStruct;
-}
-
-#endif
-
#include "mysqlconnection.moc"
--- trunk/koffice/kexi/kexidb/drivers/mySQL/mysqlconnection.h #504729:504730
@@ -46,8 +46,6 @@
virtual Cursor* prepareQuery( const QString& statement = QString::null, uint \
cursor_options = 0 ); virtual Cursor* prepareQuery( QuerySchema& query, uint \
cursor_options = 0 );
- virtual QString escapeString( const QString& str) const;
- virtual QCString escapeString( const QCString& str) const;
virtual PreparedStatement::Ptr prepareStatement(PreparedStatement::StatementType \
type, TableSchema& tableSchema);
--- trunk/koffice/kexi/kexidb/drivers/mySQL/mysqlcursor.cpp #504729:504730
@@ -24,6 +24,7 @@
#include <kexidb/error.h>
#include <klocale.h>
#include <kdebug.h>
+#include <limits.h>
#define BOOL bool
@@ -138,13 +139,13 @@
//! see SQLiteCursor::storeCurrentRow()
data.resize(m_fieldCount);
- const uint fieldsExpandedCount = m_fieldsExpanded->count();
+ const uint fieldsExpandedCount = m_fieldsExpanded ? m_fieldsExpanded->count() : \
UINT_MAX; const uint realCount = QMIN(fieldsExpandedCount, m_fieldCount);
for( uint i=0; i<realCount; i++) {
- Field *f = m_fieldsExpanded->at(i)->field;
- if (!f)
+ Field *f = m_fieldsExpanded ? m_fieldsExpanded->at(i)->field : 0;
+ if (m_fieldsExpanded && !f)
continue;
- if (f->type()==Field::BLOB) {
+ if (f && f->type()==Field::BLOB) {
QByteArray ba;
ba.duplicate(d->mysqlrow[i], d->mysqlres->lengths[i]);
data[i] = ba;
--- trunk/koffice/kexi/kexidb/drivers/mySQL/mysqldriver.cpp #504729:504730
@@ -123,7 +123,7 @@
if (ch == '\\' || ch == '\'' || ch == '"' || ch == '\n' || ch == '\r' || ch == \
'\t' || ch == '\b' || ch == '\0') break;
}
- if (i >= old_length) { //no characters to escapt
+ if (i >= old_length) { //no characters to escape
return QString::fromLatin1("'") + str + QString::fromLatin1("'");
}
@@ -133,13 +133,13 @@
new_string[new_length++] = '\''; //prepend '
for ( i = 0; i < old_length; i++, new_length++ ) {
const unsigned int ch = str[i].unicode();
- if (ch < 32) {//check for speedup
- if (ch == '\\') {
+ if (ch == '\\') {
+ new_string[new_length++] = '\\';
+ new_string[new_length] = '\\';
+ }
+ else if (ch <= '\'') {//check for speedup
+ if (ch == '\'') {
new_string[new_length++] = '\\';
- new_string[new_length] = '\\';
- }
- else if (ch == '\'') {
- new_string[new_length++] = '\\';
new_string[new_length] = '\'';
}
else if (ch == '"') {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic