Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 696870 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/plugins/sqldrivers/psql/qsql_psql.cpp (-19 / +24 lines)
Lines 1078-1085 static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) Link Here
1078
        return QPSQLDriver::Version10;
1078
        return QPSQLDriver::Version10;
1079
    case 11:
1079
    case 11:
1080
        return QPSQLDriver::Version11;
1080
        return QPSQLDriver::Version11;
1081
    case 12:
1082
        return QPSQLDriver::Version12;
1081
    default:
1083
    default:
1082
        if (vMaj > 11)
1084
        if (vMaj > 12)
1083
            return QPSQLDriver::UnknownLaterVersion;
1085
            return QPSQLDriver::UnknownLaterVersion;
1084
        break;
1086
        break;
1085
    }
1087
    }
Lines 1439-1464 QSqlRecord QPSQLDriver::record(const QString &tablename) const Link Here
1439
    else
1441
    else
1440
        schema = std::move(schema).toLower();
1442
        schema = std::move(schema).toLower();
1441
1443
1442
    QString stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
1444
    const QString adsrc = protocol() < Version8
1443
                                 "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
1445
        ? QStringLiteral("pg_attrdef.adsrc")
1444
                                 "pg_attrdef.adsrc "
1446
        : QStringLiteral("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid)");
1445
                                 "from pg_class, pg_attribute "
1447
    const QString nspname = schema.isEmpty()
1446
                                 "left join pg_attrdef on (pg_attrdef.adrelid = "
1448
        ? QStringLiteral("pg_table_is_visible(pg_class.oid)")
1447
                                 "pg_attribute.attrelid and pg_attrdef.adnum = pg_attribute.attnum) "
1449
        : QStringLiteral("pg_class.relnamespace = (SELECT oid FROM "
1448
                                 "where %1 "
1450
                         "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema);
1449
                                 "and pg_class.relname = '%2' "
1451
    const QString stmt =
1450
                                 "and pg_attribute.attnum > 0 "
1452
        QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
1451
                                 "and pg_attribute.attrelid = pg_class.oid "
1453
                       "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
1452
                                 "and pg_attribute.attisdropped = false "
1454
                       "%1 "
1453
                                 "order by pg_attribute.attnum");
1455
                       "FROM pg_class, pg_attribute "
1454
    if (schema.isEmpty())
1456
                       "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = "
1455
        stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid)"));
1457
                       "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) "
1456
    else
1458
                       "WHERE %2 "
1457
        stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from "
1459
                       "AND pg_class.relname = '%3' "
1458
                                            "pg_namespace where pg_namespace.nspname = '%1')").arg(schema));
1460
                       "AND pg_attribute.attnum > 0 "
1461
                       "AND pg_attribute.attrelid = pg_class.oid "
1462
                       "AND pg_attribute.attisdropped = false "
1463
                       "ORDER BY pg_attribute.attnum").arg(adsrc, nspname, tbl);
1459
1464
1460
    QSqlQuery query(createResult());
1465
    QSqlQuery query(createResult());
1461
    query.exec(stmt.arg(tbl));
1466
    query.exec(stmt);
1462
    while (query.next()) {
1467
    while (query.next()) {
1463
        int len = query.value(3).toInt();
1468
        int len = query.value(3).toInt();
1464
        int precision = query.value(4).toInt();
1469
        int precision = query.value(4).toInt();
(-)a/src/plugins/sqldrivers/psql/qsql_psql_p.h (-1 / +1 lines)
Lines 93-98 public: Link Here
93
        Version9_6 = 22,
93
        Version9_6 = 22,
94
        Version10 = 23,
94
        Version10 = 23,
95
        Version11 = 24,
95
        Version11 = 24,
96
        Version12 = 25,
96
        UnknownLaterVersion = 100000
97
        UnknownLaterVersion = 100000
97
    };
98
    };
98
99
99
- 

Return to bug 696870