Kexi API Documentation (2.0 alpha)

connection.cpp File Reference

#include <kexidb/connection.h>
#include "error.h"
#include "connection_p.h"
#include "connectiondata.h"
#include "driver.h"
#include "driver_p.h"
#include "schemadata.h"
#include "tableschema.h"
#include "relationship.h"
#include "transaction.h"
#include "cursor.h"
#include "global.h"
#include "roweditbuffer.h"
#include "utils.h"
#include "dbproperties.h"
#include "lookupfieldschema.h"
#include "parser/parser.h"
#include <kexiutils/utils.h>
#include <kexiutils/identifier.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qguardedptr.h>
#include <qdom.h>
#include <klocale.h>
#include <kdebug.h>
#include "connection.moc"

Go to the source code of this file.

Namespaces

namespace  KexiDB

Defines

#define KEXIDB_EXTENDED_TABLE_SCHEMA_VERSION   1
#define createDatabase_CLOSE
#define createDatabase_ERROR   { createDatabase_CLOSE; return false; }
#define C_A(a)   , const QVariant& c ## a
#define V_A0   m_driver->valueToSQL( tableSchema.field(0), c0 )
#define V_A(a)
#define C_INS_REC(args, vals)
#define C_INS_REC_ALL
#define V_A0   value += m_driver->valueToSQL( flist->first(), c0 );
#define V_A(a)   value += ("," + m_driver->valueToSQL( flist->next(), c ## a ));
#define C_INS_REC(args, vals)
#define createTable_ERR
#define alterTableName_ERR   tableSchema.setName(oldTableName)
#define SET_ERR_TRANS_NOT_SUPP
#define SET_BEGIN_TR_ERROR
#define loadExtendedTableSchemaData_ERR
#define loadExtendedTableSchemaData_ERR2(details)
#define loadExtendedTableSchemaData_ERR3(data)

Functions

static FieldListcreateFieldListForKexi__Fields (TableSchema *kexi__fieldsSchema)
 Creates a Field list for kexi__fields, for sanity. Used by createTable().
void buildValuesForKexi__Fields (QValueList< QVariant > &vals, Field *f)
 builds a list of values for field's f properties. Used by createTable().
static void createExtendedTableSchemaMainElementIfNeeded (QDomDocument &doc, QDomElement &extendedTableSchemaMainEl, bool &extendedTableSchemaStringIsEmpty)
 Used by addFieldPropertyToExtendedTableSchemaData().
static void createExtendedTableSchemaFieldElementIfNeeded (QDomDocument &doc, QDomElement &extendedTableSchemaMainEl, const QString &fieldName, QDomElement &extendedTableSchemaFieldEl)
 Used by addFieldPropertyToExtendedTableSchemaData().
static void addFieldPropertyToExtendedTableSchemaData (Field *f, const char *propertyName, const QVariant &propertyValue, QDomDocument &doc, QDomElement &extendedTableSchemaMainEl, QDomElement &extendedTableSchemaFieldEl, bool &extendedTableSchemaStringIsEmpty, bool custom=false)
void updateRowDataWithNewValues (QuerySchema &query, RowData &data, KexiDB::RowEditBuffer::DBMap &b, QMap< QueryColumnInfo *, int > &columnsOrderExpanded)

Variables

QStringList KexiDB_kexiDBSystemTableNames
 static: list of internal KexiDB system table names


Define Documentation

#define alterTableName_ERR   tableSchema.setName(oldTableName)
 

Referenced by KexiDB::Connection::alterTableName().

#define C_A  )     , const QVariant& c ## a
 

Definition at line 937 of file connection.cpp.

#define C_INS_REC args,
vals   ) 
 

Value:

bool Connection::insertRecord(FieldList& fields args) \
    { \
        QString value; \
        Field::List *flist = fields.fields(); \
        vals \
        return executeSQL( \
            QString("INSERT INTO ") + \
        ((fields.fields()->first() && fields.fields()->first()->table()) ? \
            escapeIdentifier(fields.fields()->first()->table()->name()) : \
            "??") \
        + "(" + fields.sqlFieldsList(m_driver) + ") VALUES (" + value + ")" \
        ); \
    }

Definition at line 975 of file connection.cpp.

#define C_INS_REC args,
vals   ) 
 

Value:

bool Connection::insertRecord(KexiDB::TableSchema &tableSchema args) {\
        return executeSQL( \
         QString("INSERT INTO ") + escapeIdentifier(tableSchema.name()) + " VALUES (" + vals + ")" \
        ); \
    }

Definition at line 975 of file connection.cpp.

#define C_INS_REC_ALL
 

Value:

C_INS_REC( C_A(0), V_A0 ) \
C_INS_REC( C_A(0) C_A(1), V_A0 V_A(1) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2), V_A0 V_A(1) V_A(2) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2) C_A(3), V_A0 V_A(1) V_A(2) V_A(3) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2) C_A(3) C_A(4), V_A0 V_A(1) V_A(2) V_A(3) V_A(4) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2) C_A(3) C_A(4) C_A(5), V_A0 V_A(1) V_A(2) V_A(3) V_A(4) V_A(5) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2) C_A(3) C_A(4) C_A(5) C_A(6), V_A0 V_A(1) V_A(2) V_A(3) V_A(4) V_A(5) V_A(6) ) \
C_INS_REC( C_A(0) C_A(1) C_A(2) C_A(3) C_A(4) C_A(5) C_A(6) C_A(7), V_A0 V_A(1) V_A(2) V_A(3) V_A(4) V_A(5) V_A(6) V_A(7) )

Definition at line 954 of file connection.cpp.

#define createDatabase_CLOSE
 

Value:

{ if (!closeDatabase()) { \
        setError(i18n("Database \"%1\" created but could not be closed after creation.").arg(dbName) ); \
        return false; \
    } }

Definition at line 424 of file connection.cpp.

Referenced by KexiDB::Connection::createDatabase().

#define createDatabase_ERROR   { createDatabase_CLOSE; return false; }
 

Definition at line 430 of file connection.cpp.

Referenced by KexiDB::Connection::createDatabase().

#define createTable_ERR
 

Value:

{ KexiDBDbg << "Connection::createTable(): ERROR!" <<endl; \
      setError(this, i18n("Creating table failed.")); \
      rollbackAutoCommitTransaction(tg.transaction()); \
      return false; }

Definition at line 1403 of file connection.cpp.

Referenced by KexiDB::Connection::createTable().

#define KEXIDB_EXTENDED_TABLE_SCHEMA_VERSION   1
 

Definition at line 50 of file connection.cpp.

Referenced by createExtendedTableSchemaMainElementIfNeeded().

#define loadExtendedTableSchemaData_ERR
 

Value:

{ setError(i18n("Error while loading extended table schema information.")); \
      return false; }

Referenced by KexiDB::Connection::loadExtendedTableSchemaData().

#define loadExtendedTableSchemaData_ERR2 details   ) 
 

Value:

{ setError(i18n("Error while loading extended table schema information."), details); \
      return false; }

Referenced by KexiDB::Connection::loadExtendedTableSchemaData().

#define loadExtendedTableSchemaData_ERR3 data   ) 
 

Value:

{ setError(i18n("Error while loading extended table schema information."), \
      i18n("Invalid XML data: ") + data.left(1024) ); \
      return false; }

Referenced by KexiDB::Connection::loadExtendedTableSchemaData().

#define SET_BEGIN_TR_ERROR
 

Value:

{ if (!error()) \
        setError(ERR_ROLLBACK_OR_COMMIT_TRANSACTION, i18n("Begin transaction failed")); }

Definition at line 1912 of file connection.cpp.

Referenced by KexiDB::Connection::beginTransaction().

#define SET_ERR_TRANS_NOT_SUPP
 

Value:

{ setError(ERR_UNSUPPORTED_DRV_FEATURE, \
     i18n("Transactions are not supported for \"%1\" driver.").arg(m_driver->name() )); }

Definition at line 1908 of file connection.cpp.

Referenced by KexiDB::Connection::beginTransaction(), KexiDB::Connection::commitTransaction(), and KexiDB::Connection::rollbackTransaction().

#define V_A  )     value += ("," + m_driver->valueToSQL( flist->next(), c ## a ));
 

Definition at line 971 of file connection.cpp.

#define V_A  ) 
 

Value:

+","+m_driver->valueToSQL( \
    tableSchema.field(a) ? tableSchema.field(a)->type() : Field::Text, c ## a )

Definition at line 971 of file connection.cpp.

#define V_A0   value += m_driver->valueToSQL( flist->first(), c0 );
 

Definition at line 970 of file connection.cpp.

#define V_A0   m_driver->valueToSQL( tableSchema.field(0), c0 )
 

Definition at line 970 of file connection.cpp.


Function Documentation

static void addFieldPropertyToExtendedTableSchemaData Field f,
const char *  propertyName,
const QVariant &  propertyValue,
QDomDocument &  doc,
QDomElement &  extendedTableSchemaMainEl,
QDomElement &  extendedTableSchemaFieldEl,
bool &  extendedTableSchemaStringIsEmpty,
bool  custom = false
[static]
 

Todo:
add more QVariant types

Definition at line 2442 of file connection.cpp.

References createExtendedTableSchemaFieldElementIfNeeded(), createExtendedTableSchemaMainElementIfNeeded(), and KexiDBFatal.

Referenced by KexiDB::Connection::storeExtendedTableSchemaData().

void buildValuesForKexi__Fields QValueList< QVariant > &  vals,
Field f
 

builds a list of values for field's f properties. Used by createTable().

Definition at line 1356 of file connection.cpp.

References KexiDB::Field::caption(), KexiDB::Field::constraints(), KexiDB::Field::defaultValue(), KexiDB::Field::description(), KexiDB::Field::isFPNumericType(), KexiDB::Field::length(), KexiDB::Field::name(), KexiDB::Field::options(), KexiDB::Field::order(), KexiDB::Field::precision(), KexiDB::Field::scale(), KexiDB::Field::table(), KexiDB::Field::type(), and KexiDB::variantToString().

Referenced by KexiDB::Connection::createTable(), and KexiDB::Connection::storeMainFieldSchema().

static void createExtendedTableSchemaFieldElementIfNeeded QDomDocument &  doc,
QDomElement &  extendedTableSchemaMainEl,
const QString fieldName,
QDomElement &  extendedTableSchemaFieldEl
[static]
 

Used by addFieldPropertyToExtendedTableSchemaData().

Definition at line 2426 of file connection.cpp.

Referenced by addFieldPropertyToExtendedTableSchemaData(), and KexiDB::Connection::storeExtendedTableSchemaData().

static void createExtendedTableSchemaMainElementIfNeeded QDomDocument &  doc,
QDomElement &  extendedTableSchemaMainEl,
bool &  extendedTableSchemaStringIsEmpty
[static]
 

Used by addFieldPropertyToExtendedTableSchemaData().

Definition at line 2412 of file connection.cpp.

References KEXIDB_EXTENDED_TABLE_SCHEMA_VERSION.

Referenced by addFieldPropertyToExtendedTableSchemaData(), and KexiDB::Connection::storeExtendedTableSchemaData().

static FieldList* createFieldListForKexi__Fields TableSchema kexi__fieldsSchema  )  [static]
 

Creates a Field list for kexi__fields, for sanity. Used by createTable().

Definition at line 1336 of file connection.cpp.

References KexiDB::FieldList::subList().

Referenced by KexiDB::Connection::createTable(), and KexiDB::Connection::storeMainFieldSchema().

void updateRowDataWithNewValues QuerySchema query,
RowData data,
KexiDB::RowEditBuffer::DBMap b,
QMap< QueryColumnInfo *, int > &  columnsOrderExpanded
[inline]
 

Definition at line 3020 of file connection.cpp.

References KexiDB::QuerySchema::columnsOrder(), KexiDB::QuerySchema::ExpandedList, and KexiDBWarn.

Referenced by KexiDB::Connection::insertRow(), and KexiDB::Connection::updateRow().


Variable Documentation

QStringList KexiDB_kexiDBSystemTableNames
 

static: list of internal KexiDB system table names

Definition at line 196 of file connection.cpp.

KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:48:59 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003