Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/drivers/mysql/qsql_mysql.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtSql module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8686        tc(0),
    8787#endif
    88         preparedQuerys(false), preparedQuerysEnabled(false) {}
     88        preparedQuerysEnabled(false) {}
    8989    MYSQL *mysql;
    9090    QTextCodec *tc;
    9191
    92     bool preparedQuerys;
    9392    bool preparedQuerysEnabled;
    9493};
     
    164163}
    165164
    166 class QMYSQLResultPrivate
    167 {
     165class QMYSQLResultPrivate : public QObject
     166{
     167    Q_OBJECT
    168168public:
    169     QMYSQLResultPrivate(QMYSQLDriverPrivate* dp) : d(dp), result(0),
     169    QMYSQLResultPrivate(const QMYSQLDriver* dp, const QMYSQLResult* d) : driver(dp), result(0), q(d),
    170170        rowsAffected(0), hasBlobs(false)
    171171#if MYSQL_VERSION_ID >= 40108
    172172        , stmt(0), meta(0), inBinds(0), outBinds(0)
    173173#endif
    174         , precisionPolicy(QSql::HighPrecision)
    175         {}
    176 
    177     QMYSQLDriverPrivate* d;
     174        , preparedQuery(false)
     175        {
     176            connect(dp, SIGNAL(destroyed()), this, SLOT(driverDestroyed()));
     177        }
     178
     179    const QMYSQLDriver* driver;
    178180    MYSQL_RES *result;
    179181    MYSQL_ROW row;
     182    const QMYSQLResult* q;
    180183
    181184    int rowsAffected;
     
    207210    MYSQL_BIND *outBinds;
    208211#endif
    209     QSql::NumericalPrecisionPolicy precisionPolicy;
     212
     213    bool preparedQuery;
     214
     215private Q_SLOTS:
     216    void driverDestroyed() { driver = NULL; }
    210217};
    211218
     
    225232                            const QMYSQLDriverPrivate* p)
    226233{
    227     const char *cerr = mysql_error(p->mysql);
     234    const char *cerr = p->mysql ? mysql_error(p->mysql) : 0;
    228235    return QSqlError(QLatin1String("QMYSQL: ") + err,
    229236                     p->tc ? toUnicode(p->tc, cerr) : QString::fromLatin1(cerr),
     
    250257    case FIELD_TYPE_FLOAT :
    251258    case FIELD_TYPE_DOUBLE :
     259    case FIELD_TYPE_DECIMAL :
     260#if defined(FIELD_TYPE_NEWDECIMAL)
     261    case FIELD_TYPE_NEWDECIMAL:
     262#endif
    252263        type = QVariant::Double;
    253264        break;
     
    273284    case FIELD_TYPE_ENUM :
    274285    case FIELD_TYPE_SET :
    275     case FIELD_TYPE_DECIMAL :
    276286        type = QVariant::String;
    277287        break;
     
    350360        QMyField &f = fields[i];
    351361        f.myField = fieldInfo;
     362
    352363        f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
    353364        if (qIsBlob(fieldInfo->type)) {
     
    380391: QSqlResult(db)
    381392{
    382     d = new QMYSQLResultPrivate(db->d);
     393    d = new QMYSQLResultPrivate(db, this);
    383394}
    384395
     
    392403{
    393404#if MYSQL_VERSION_ID >= 40108
    394     if(d->d->preparedQuerys)
     405    if(d->preparedQuery)
    395406        return d->meta ? qVariantFromValue(d->meta) : qVariantFromValue(d->stmt);
    396407    else
     
    407418// if this isn't done subsequent queries will fail with "Commands out of sync"
    408419#if MYSQL_VERSION_ID >= 40100
    409     while (d->d->mysql && mysql_next_result(d->d->mysql) == 0) {
    410         MYSQL_RES *res = mysql_store_result(d->d->mysql);
     420    while (d->driver && d->driver->d->mysql && mysql_next_result(d->driver->d->mysql) == 0) {
     421        MYSQL_RES *res = mysql_store_result(d->driver->d->mysql);
    411422        if (res)
    412423            mysql_free_result(res);
     
    447458    setAt(-1);
    448459    setActive(false);
    449 
    450     d->d->preparedQuerys = d->d->preparedQuerysEnabled;
    451460}
    452461
    453462bool QMYSQLResult::fetch(int i)
    454463{
     464    if(!d->driver)
     465        return false;
    455466    if (isForwardOnly()) { // fake a forward seek
    456467        if (at() < i) {
     
    464475    if (at() == i)
    465476        return true;
    466     if (d->d->preparedQuerys) {
     477    if (d->preparedQuery) {
    467478#if MYSQL_VERSION_ID >= 40108
    468479        mysql_stmt_data_seek(d->stmt, i);
     
    495506bool QMYSQLResult::fetchNext()
    496507{
    497     if (d->d->preparedQuerys) {
     508    if(!d->driver)
     509        return false;
     510    if (d->preparedQuery) {
    498511#if MYSQL_VERSION_ID >= 40108
    499         if (mysql_stmt_fetch(d->stmt))
     512        int nRC = mysql_stmt_fetch(d->stmt);
     513        if (nRC) {
     514#ifdef MYSQL_DATA_TRUNCATED
     515            if (nRC == 1 || nRC == MYSQL_DATA_TRUNCATED)
     516#else
     517            if (nRC == 1)
     518#endif // MYSQL_DATA_TRUNCATED
     519                setLastError(qMakeStmtError(QCoreApplication::translate("QMYSQLResult",
     520                                    "Unable to fetch data"), QSqlError::StatementError, d->stmt));
    500521            return false;
     522        }
    501523#else
    502524        return false;
    503525#endif
    504526    } else {
    505     d->row = mysql_fetch_row(d->result);
    506     if (!d->row)
    507         return false;
     527        d->row = mysql_fetch_row(d->result);
     528        if (!d->row)
     529            return false;
    508530    }
    509531    setAt(at() + 1);
     
    513535bool QMYSQLResult::fetchLast()
    514536{
     537    if(!d->driver)
     538        return false;
    515539    if (isForwardOnly()) { // fake this since MySQL can't seek on forward only queries
    516540        bool success = fetchNext(); // did we move at all?
     
    520544
    521545    my_ulonglong numRows;
    522     if (d->d->preparedQuerys) {
     546    if (d->preparedQuery) {
    523547#if MYSQL_VERSION_ID >= 40108
    524548        numRows = mysql_stmt_num_rows(d->stmt);
     
    554578    }
    555579
     580    if (!d->driver)
     581        return QVariant();
     582
    556583    int fieldLength = 0;
    557584    const QMYSQLResultPrivate::QMyField &f = d->fields.at(field);
    558585    QString val;
    559     if (d->d->preparedQuerys) {
     586    if (d->preparedQuery) {
    560587        if (f.nullIndicator)
    561588            return QVariant(f.type);
    562589
    563590        if (f.type != QVariant::ByteArray)
    564             val = toUnicode(d->d->tc, f.outField, f.bufLength);
     591            val = toUnicode(d->driver->d->tc, f.outField, f.bufLength);
    565592    } else {
    566593        if (d->row[field] == NULL) {
     
    570597        fieldLength = mysql_fetch_lengths(d->result)[field];
    571598        if (f.type != QVariant::ByteArray)
    572             val = toUnicode(d->d->tc, d->row[field], fieldLength);
     599            val = toUnicode(d->driver->d->tc, d->row[field], fieldLength);
    573600    }
    574601
     
    585612        QVariant v;
    586613        bool ok=false;
    587         switch(d->precisionPolicy) {
     614        double dbl = val.toDouble(&ok);
     615        switch(numericalPrecisionPolicy()) {
    588616            case QSql::LowPrecisionInt32:
    589                 v=val.toInt(&ok);
     617                v=QVariant(dbl).toInt();
    590618                break;
    591619            case QSql::LowPrecisionInt64:
    592                 v = val.toLongLong(&ok);
     620                v = QVariant(dbl).toLongLong();
    593621                break;
    594622            case QSql::LowPrecisionDouble:
    595                 v = val.toDouble(&ok);
     623                v = QVariant(dbl);
    596624                break;
    597625            case QSql::HighPrecision:
     
    606634            return QVariant();
    607635    }
     636        return QVariant(val.toDouble());
    608637    case QVariant::Date:
    609638        return qDateFromString(val);
     
    615644
    616645        QByteArray ba;
    617         if (d->d->preparedQuerys) {
     646        if (d->preparedQuery) {
    618647            ba = QByteArray(f.outField, f.bufLength);
    619648        } else {
     
    632661bool QMYSQLResult::isNull(int field)
    633662{
    634    if (d->d->preparedQuerys)
     663   if (d->preparedQuery)
    635664       return d->fields.at(field).nullIndicator;
    636665   else
     
    640669bool QMYSQLResult::reset (const QString& query)
    641670{
    642     if (!driver() || !driver()->isOpen() || driver()->isOpenError())
    643         return false;
    644 
    645     if(d->d->preparedQuerysEnabled && prepare(query)) {
    646         d->d->preparedQuerys = true;
    647         return exec();
    648     }
    649     d->d->preparedQuerys = false;
    650 
    651     const QByteArray encQuery(fromUnicode(d->d->tc, query));
    652     if (mysql_real_query(d->d->mysql, encQuery.data(), encQuery.length())) {
     671    if (!driver() || !driver()->isOpen() || driver()->isOpenError() || !d->driver)
     672        return false;
     673
     674    d->preparedQuery = false;
     675
     676    cleanup();
     677
     678    const QByteArray encQuery(fromUnicode(d->driver->d->tc, query));
     679    if (mysql_real_query(d->driver->d->mysql, encQuery.data(), encQuery.length())) {
    653680        setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to execute query"),
    654                      QSqlError::StatementError, d->d));
    655         return false;
    656     }
    657     d->result = mysql_store_result(d->d->mysql);
    658     if (!d->result && mysql_field_count(d->d->mysql) > 0) {
     681                     QSqlError::StatementError, d->driver->d));
     682        return false;
     683    }
     684    d->result = mysql_store_result(d->driver->d->mysql);
     685    if (!d->result && mysql_field_count(d->driver->d->mysql) > 0) {
    659686        setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to store result"),
    660                     QSqlError::StatementError, d->d));
    661         return false;
    662     }
    663     int numFields = mysql_field_count(d->d->mysql);
     687                    QSqlError::StatementError, d->driver->d));
     688        return false;
     689    }
     690    int numFields = mysql_field_count(d->driver->d->mysql);
    664691    setSelect(numFields != 0);
    665692    d->fields.resize(numFields);
    666     d->rowsAffected = mysql_affected_rows(d->d->mysql);
     693    d->rowsAffected = mysql_affected_rows(d->driver->d->mysql);
     694
    667695    if (isSelect()) {
    668696        for(int i = 0; i < numFields; i++) {
     
    678706int QMYSQLResult::size()
    679707{
    680     if (isSelect())
    681         if (d->d->preparedQuerys)
     708    if (d->driver && isSelect())
     709        if (d->preparedQuery)
    682710#if MYSQL_VERSION_ID >= 40108
    683711            return mysql_stmt_num_rows(d->stmt);
     
    698726QVariant QMYSQLResult::lastInsertId() const
    699727{
    700     if (!isActive())
     728    if (!isActive() || !d->driver)
    701729        return QVariant();
    702730
    703     if (d->d->preparedQuerys) {
     731    if (d->preparedQuery) {
    704732#if MYSQL_VERSION_ID >= 40108
    705733        quint64 id = mysql_stmt_insert_id(d->stmt);
     
    708736#endif
    709737    } else {
    710         quint64 id = mysql_insert_id(d->d->mysql);
     738        quint64 id = mysql_insert_id(d->driver->d->mysql);
    711739        if (id)
    712740            return QVariant(id);
     
    719747    QSqlRecord info;
    720748    MYSQL_RES *res;
    721     if (!isActive() || !isSelect())
     749    if (!isActive() || !isSelect() || !d->driver)
    722750        return info;
    723751
    724752#if MYSQL_VERSION_ID >= 40108
    725     res = d->d->preparedQuerys ? d->meta : d->result;
     753    res = d->preparedQuery ? d->meta : d->result;
    726754#else
    727755    res = d->result;
    728756#endif
    729757
    730     if (!mysql_errno(d->d->mysql)) {
     758    if (!mysql_errno(d->driver->d->mysql)) {
    731759        mysql_field_seek(res, 0);
    732760        MYSQL_FIELD* field = mysql_fetch_field(res);
    733761        while(field) {
    734             info.append(qToField(field, d->d->tc));
     762            info.append(qToField(field, d->driver->d->tc));
    735763            field = mysql_fetch_field(res);
    736764        }
     
    742770bool QMYSQLResult::nextResult()
    743771{
     772    if(!d->driver)
     773        return false;
    744774#if MYSQL_VERSION_ID >= 40100
    745775    setAt(-1);
     
    755785    d->fields.clear();
    756786
    757     int status = mysql_next_result(d->d->mysql);
     787    int status = mysql_next_result(d->driver->d->mysql);
    758788    if (status > 0) {
    759789        setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to execute next query"),
    760                      QSqlError::StatementError, d->d));
     790                     QSqlError::StatementError, d->driver->d));
    761791        return false;
    762792    } else if (status == -1) {
     
    764794    }
    765795
    766     d->result = mysql_store_result(d->d->mysql);
    767     int numFields = mysql_field_count(d->d->mysql);
     796    d->result = mysql_store_result(d->driver->d->mysql);
     797    int numFields = mysql_field_count(d->driver->d->mysql);
    768798    if (!d->result && numFields > 0) {
    769799        setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to store next result"),
    770                      QSqlError::StatementError, d->d));
     800                     QSqlError::StatementError, d->driver->d));
    771801        return false;
    772802    }
     
    774804    setSelect(numFields > 0);
    775805    d->fields.resize(numFields);
    776     d->rowsAffected = mysql_affected_rows(d->d->mysql);
     806    d->rowsAffected = mysql_affected_rows(d->driver->d->mysql);
    777807
    778808    if (isSelect()) {
     
    797827        *static_cast<bool*>(data) = nextResult();
    798828        break;
    799     case QSqlResult::SetNumericalPrecision:
    800         Q_ASSERT(data);
    801         d->precisionPolicy = *reinterpret_cast<QSql::NumericalPrecisionPolicy *>(data);
    802         break;
    803829    default:
    804830        QSqlResult::virtual_hook(id, data);
     
    834860bool QMYSQLResult::prepare(const QString& query)
    835861{
     862    if(!d->driver)
     863        return false;
    836864#if MYSQL_VERSION_ID >= 40108
    837865    cleanup();
    838     if (!d->d->preparedQuerys)
     866    if (!d->driver->d->preparedQuerysEnabled)
    839867        return QSqlResult::prepare(query);
    840868
     
    845873
    846874    if (!d->stmt)
    847         d->stmt = mysql_stmt_init(d->d->mysql);
     875        d->stmt = mysql_stmt_init(d->driver->d->mysql);
    848876    if (!d->stmt) {
    849877        setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to prepare statement"),
    850                      QSqlError::StatementError, d->d));
    851         return false;
    852     }
    853 
    854     const QByteArray encQuery(fromUnicode(d->d->tc, query));
     878                     QSqlError::StatementError, d->driver->d));
     879        return false;
     880    }
     881
     882    const QByteArray encQuery(fromUnicode(d->driver->d->tc, query));
    855883    r = mysql_stmt_prepare(d->stmt, encQuery.constData(), encQuery.length());
    856884    if (r != 0) {
     
    866894
    867895    setSelect(d->bindInValues());
     896    d->preparedQuery = true;
    868897    return true;
    869898#else
     
    874903bool QMYSQLResult::exec()
    875904{
    876     if (!d->d->preparedQuerys)
     905    if (!d->driver)
     906        return false;
     907    if (!d->preparedQuery)
    877908        return QSqlResult::exec();
    878909    if (!d->stmt)
     
    907938            currBind->is_null = &nullVector[i];
    908939            currBind->length = 0;
     940            currBind->is_unsigned = 0;
    909941
    910942            switch (val.type()) {
     
    953985                    currBind->buffer = data;
    954986                    currBind->buffer_length = sizeof(double);
    955                     currBind->is_unsigned = 0;
    956987                    break;
    957988                case QVariant::LongLong:
     
    964995                case QVariant::String:
    965996                default: {
    966                     QByteArray ba = fromUnicode(d->d->tc, val.toString());
     997                    QByteArray ba = fromUnicode(d->driver->d->tc, val.toString());
    967998                    stringVector.append(ba);
    968999                    currBind->buffer_type = MYSQL_TYPE_STRING;
    9691000                    currBind->buffer = const_cast<char *>(ba.constData());
    9701001                    currBind->buffer_length = ba.length();
    971                     currBind->is_unsigned = 0;
    9721002                    break; }
    9731003            }
     
    11291159    case BatchOperations:
    11301160    case SimpleLocking:
    1131     case LowPrecisionNumbers:
    11321161    case EventNotifications:
    11331162    case FinishQuery:
     
    11371166    case LastInsertId:
    11381167    case Unicode:
     1168    case LowPrecisionNumbers:
    11391169        return true;
    11401170    case PreparedQueries:
     
    11931223    const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));
    11941224    QString unixSocket;
     1225#if MYSQL_VERSION_ID >= 50000
     1226    my_bool reconnect=false;
     1227#endif
    11951228
    11961229    // extract the real options from the string
     
    12031236            if (opt == QLatin1String("UNIX_SOCKET"))
    12041237                unixSocket = val;
     1238#if MYSQL_VERSION_ID >= 50000
     1239            else if (opt == QLatin1String("MYSQL_OPT_RECONNECT")) {
     1240                if (val == QLatin1String("TRUE") || val == QLatin1String("1") || val.isEmpty())
     1241                    reconnect = true;
     1242            }
     1243#endif
    12051244            else if (val == QLatin1String("TRUE") || val == QLatin1String("1"))
    12061245                setOptionFlag(optionFlags, tmp.left(idx).simplified());
     
    12351274            return false;
    12361275        }
     1276#if MYSQL_VERSION_ID >= 50000
     1277        if(reconnect)
     1278            mysql_options(d->mysql, MYSQL_OPT_RECONNECT, &reconnect);
     1279#endif
    12371280    } else {
    12381281        setLastError(qMakeError(tr("Unable to connect"),
     
    12591302#endif
    12601303
     1304#ifndef QT_NO_THREAD
     1305    mysql_thread_init();
     1306#endif
     1307
     1308
    12611309    setOpen(true);
    12621310    setOpenError(false);
     
    12671315{
    12681316    if (isOpen()) {
     1317#ifndef QT_NO_THREAD
     1318        mysql_thread_end();
     1319#endif
    12691320        mysql_close(d->mysql);
    12701321        d->mysql = NULL;
     
    12821333{
    12831334    QStringList tl;
    1284     if (!isOpen())
    1285         return tl;
    1286     if (!(type & QSql::Tables))
    1287         return tl;
    1288 
    1289     MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL);
    1290     MYSQL_ROW row;
    1291     int i = 0;
    1292     while (tableRes) {
    1293         mysql_data_seek(tableRes, i);
    1294         row = mysql_fetch_row(tableRes);
    1295         if (!row)
    1296             break;
    1297         tl.append(toUnicode(d->tc, row[0]));
    1298         i++;
    1299     }
    1300     mysql_free_result(tableRes);
     1335#if MYSQL_VERSION_ID >= 40100
     1336    if( mysql_get_server_version(d->mysql) < 50000)
     1337    {
     1338#endif
     1339        if (!isOpen())
     1340            return tl;
     1341        if (!(type & QSql::Tables))
     1342            return tl;
     1343
     1344        MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL);
     1345        MYSQL_ROW row;
     1346        int i = 0;
     1347        while (tableRes) {
     1348            mysql_data_seek(tableRes, i);
     1349            row = mysql_fetch_row(tableRes);
     1350            if (!row)
     1351                break;
     1352            tl.append(toUnicode(d->tc, row[0]));
     1353            i++;
     1354        }
     1355        mysql_free_result(tableRes);
     1356#if MYSQL_VERSION_ID >= 40100
     1357    } else {
     1358        QSqlQuery q(createResult());
     1359        if(type & QSql::Tables) {
     1360            q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'BASE TABLE'"));
     1361            while(q.next())
     1362                tl.append(q.value(0).toString());
     1363        }
     1364        if(type & QSql::Views) {
     1365            q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'VIEW'"));
     1366            while(q.next())
     1367                tl.append(q.value(0).toString());
     1368        }
     1369    }
     1370#endif
    13011371    return tl;
    13021372}
     
    13051375{
    13061376    QSqlIndex idx;
    1307     bool prepQ;
    13081377    if (!isOpen())
    13091378        return idx;
    1310 
    1311     prepQ = d->preparedQuerys;
    1312     d->preparedQuerys = false;
    13131379
    13141380    QSqlQuery i(createResult());
    13151381    QString stmt(QLatin1String("show index from %1;"));
    13161382    QSqlRecord fil = record(tablename);
    1317     i.exec(stmt.arg(escapeIdentifier(tablename, QSqlDriver::TableName)));
     1383    i.exec(stmt.arg(tablename));
    13181384    while (i.isActive() && i.next()) {
    13191385        if (i.value(2).toString() == QLatin1String("PRIMARY")) {
     
    13241390    }
    13251391
    1326     d->preparedQuerys = prepQ;
    13271392    return idx;
    13281393}
     
    13301395QSqlRecord QMYSQLDriver::record(const QString& tablename) const
    13311396{
     1397    QString table=tablename;
     1398    if(isIdentifierEscaped(table, QSqlDriver::TableName))
     1399        table = stripDelimiters(table, QSqlDriver::TableName);
     1400
    13321401    QSqlRecord info;
    13331402    if (!isOpen())
    13341403        return info;
    1335     MYSQL_RES* r = mysql_list_fields(d->mysql, tablename.toLocal8Bit().constData(), 0);
     1404    MYSQL_RES* r = mysql_list_fields(d->mysql, table.toLocal8Bit().constData(), 0);
    13361405    if (!r) {
    13371406        return info;
    13381407    }
    13391408    MYSQL_FIELD* field;
     1409
    13401410    while ((field = mysql_fetch_field(r)))
    13411411        info.append(qToField(field, d->tc));
     
    14371507{
    14381508    QString res = identifier;
    1439     if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('`')) && identifier.right(1) != QString(QLatin1Char('`')) ) {
     1509    if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('`')) && !identifier.endsWith(QLatin1Char('`')) ) {
    14401510        res.prepend(QLatin1Char('`')).append(QLatin1Char('`'));
    14411511        res.replace(QLatin1Char('.'), QLatin1String("`.`"));
     
    14441514}
    14451515
     1516bool QMYSQLDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
     1517{
     1518    Q_UNUSED(type);
     1519    return identifier.size() > 2
     1520        && identifier.startsWith(QLatin1Char('`')) //left delimited
     1521        && identifier.endsWith(QLatin1Char('`')); //right delimited
     1522}
     1523
    14461524QT_END_NAMESPACE
     1525
     1526#include "qsql_mysql.moc"
  • trunk/src/sql/drivers/mysql/qsql_mysql.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtSql module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7070{
    7171    friend class QMYSQLDriver;
     72    friend class QMYSQLResultPrivate;
    7273public:
    7374    explicit QMYSQLResult(const QMYSQLDriver* db);
     
    124125    QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
    125126
     127protected Q_SLOTS:
     128    bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
     129
    126130protected:
    127131    bool beginTransaction();
Note: See TracChangeset for help on using the changeset viewer.