Modified:
MYSQLPlus/MYSQLPlusLib/MDescriptorRecord.h
MYSQLPlus/MYSQLPlusLib/MResult.cpp
MYSQLPlus/MYSQLPlusLib/MResult.h
MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
MYSQLPlus/MYSQLPlusLib/MResultPlus.h
MYSQLPlus/MYSQLPlusLib/MResultRes.cpp
MYSQLPlus/MYSQLPlusLib/MResultRes.h
MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
MYSQLPlus/MYSQLPlusLib/MResultStmt.h
Log:
Modified: MYSQLPlus/MYSQLPlusLib/MDescriptorRecord.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MDescriptorRecord.h 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MDescriptorRecord.h 2006-06-02 05:36:39 UTC (rev 311)
@@ -32,6 +32,7 @@
{
friend class MDescriptor;
friend class MResult;
+ friend class MResultPlus;
friend class MResultRes;
friend class MResultStmt;
public:
Modified: MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-06-02 05:36:39 UTC (rev 311)
@@ -1875,4 +1875,416 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
+/*!
+ \brief Appends an IRD record describing the given field.
+ This is all about mapping our MySQL field description (MYSQL_FIELD) to our
ODBC
+ column description (IRD).
+
+ \param nField
+ \param pField
+
+ \return SQLRETURN
+
+ \sa doLoadMetaData
+*/
+SQLRETURN MResult::doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField,
MDescriptorIRD *pDescriptor )
+{
+ MYODBCDbgEnter();
+
+ if ( !pField )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid field structure. Failed to store field descriptor information.") ) );
+
+ if ( nField > (unsigned int)pDescriptor->getCount() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Field index out of range. Failed to store field descriptor information.") ) );
+
+ /*
+ WARNING!!!
+
+ This function needs to be revisited and reviewed - probably several times.
+
+ This is a blend of my interpretation (1st pass kind of thing) and what
+ is found in the old driver. Some of what is in here is certianly in
+ need if some changing.
+ */
+
+ /*
+ common
+
+ All fields are included (in alpha order) for completeness. Comments
+ are made to state why some are not relevant. Again; there may be
+ calculated fields in here which are set now with the thinking that
+ it will make maintaining and working with the whole descriptor
+ business easier (for example; desc_label which could be just mapped
+ to desc_name as needed but is set now).
+
+ These must be handled before the type specific ones because in some
+ cases the values set here are replaced depending upon the type -
+ but only sometimes.
+ */
+ MDescriptorRecord *pDescriptorRecord = pDescriptor->getRecord( nField );
+
+ pDescriptorRecord->setAutoUniqueValue( (pField->flags &&
AUTO_INCREMENT_FLAG) ? SQL_TRUE : SQL_FALSE );
+ pDescriptorRecord->setBaseColumnName( (pField->org_name ? pField->org_name :
"") );
+ pDescriptorRecord->setBaseTableName( (pField->org_table ? pField->org_table
: "") );
+ pDescriptorRecord->setCaseSensitive( (pField->flags & BINARY_FLAG ?
SQL_FALSE : SQL_TRUE) );
+ pDescriptorRecord->setCatalogName( (pField->catalog ? pField->catalog : "")
);
+/* pDescriptorRecord->setconcise_type; - type specific */
+/* pDescriptorRecord->setdata_ptr; - N/A */
+/* pDescriptorRecord->setdatetime_interval_code; - type specific */
+ pDescriptorRecord->setDatetimeIntervalPrecision( 10 ); /* this is a
conservative guess - not sure what precision we get when we diff 2 times */
+ pDescriptorRecord->setDisplaySize( pField->max_length ); /* - also type
specific */
+ pDescriptorRecord->setFixedPrecScale( SQL_FALSE ); /* - also type
specific */
+/* pDescriptorRecord->setindicator_ptr; - N/A */
+ pDescriptorRecord->setLabel( pField->name );
+/* pDescriptorRecord->setlength; - type specific */
+/* pDescriptorRecord->setliteral_prefix; - type specific */
+/* pDescriptorRecord->setliteral_suffix; - type specific */
+ pDescriptorRecord->setLocalTypeName( "" );
+ pDescriptorRecord->setName( pField->name );
+ pDescriptorRecord->setNullable( ((pField->flags && NOT_NULL_FLAG) ?
SQL_NO_NULLS : SQL_NULLABLE) );
+/* pDescriptorRecord->setnum_prec_radix; - type specific */
+/* pDescriptorRecord->setoctet_length; - type specific */
+/* pDescriptorRecord->setoctet_length_ptr; - N/A */
+/* pDescriptorRecord->setparamter_type; - N/A */
+/* pDescriptorRecord->setprecision; - type specific */
+ pDescriptorRecord->setRowver( SQL_FALSE ); /* - also type specific */
+ pDescriptorRecord->setScale( pField->decimals );
+ pDescriptorRecord->setSchemaName( pField->db );
+ pDescriptorRecord->setSearchable( SQL_PRED_SEARCHABLE );
+ pDescriptorRecord->setTableName( pField->table );
+/* pDescriptorRecord->settype; - type specific */
+/* pDescriptorRecord->settype_name; - type specific */
+ pDescriptorRecord->setUnnamed( SQL_NAMED );
+ pDescriptorRecord->setUnsigned( (pField->flags & UNSIGNED_FLAG ? SQL_TRUE :
SQL_FALSE) );
+ pDescriptorRecord->setUpdatable( (pField->table && pField->table[0]
? SQL_ATTR_READWRITE_UNKNOWN : SQL_ATTR_READONLY) );
+
+ /*
+ set type specific values here
+
+ All supported mysql field types in *alpha* order (for readability).
+
+ Many descriptor fields can be set without much regard to the type
+ or are may not even be used given that we are an IRD.
+
+ The ones set in this switch/case are special cases where the
+ values are dependent upon the type. Note that MYODBCDesRecType
+ does set some related fields in the descriptor to ensure that
+ the related fields are valid.
+ */
+ switch ( pField->type )
+ {
+ case MYSQL_TYPE_BLOB:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ if ( pField->flags & BINARY_FLAG )
+ {
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setTypeName( "blob" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
+ }
+ else
+ {
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setTypeName( "text" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
+ }
+ break;
+ case MYSQL_TYPE_DATE:
+ pDescriptorRecord->setDisplaySize( 10 );
+ pDescriptorRecord->setLength( 10 );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( 10 );
+ pDescriptorRecord->setTypeName( "date" );
+ pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
+ break;
+ case MYSQL_TYPE_DATETIME:
+ pDescriptorRecord->setDisplaySize( 19 );
+ pDescriptorRecord->setLength( 19 );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( 19 );
+ pDescriptorRecord->setTypeName( "datetime" );
+ pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
+ break;
+ case MYSQL_TYPE_DECIMAL:
+ pDescriptorRecord->setDisplaySize( max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
+ pDescriptorRecord->setFixedPrecScale( pField->decimals ? SQL_TRUE :
SQL_FALSE );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 10 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
+ pDescriptorRecord->setTypeName( "decimal" );
+ pDescriptorRecord->setConciseType( SQL_DECIMAL );
+ break;
+ case MYSQL_TYPE_DOUBLE:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "double unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "double" );
+ pDescriptorRecord->setConciseType( SQL_DOUBLE );
+ break;
+ case MYSQL_TYPE_ENUM:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setTypeName( "enum" );
+ pDescriptorRecord->setConciseType( SQL_CHAR );
+ break;
+ case MYSQL_TYPE_FLOAT:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "float unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "float" );
+ pDescriptorRecord->setConciseType( SQL_REAL );
+ break;
+ case MYSQL_TYPE_GEOMETRY:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setTypeName( "blob" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
+ break;
+ case MYSQL_TYPE_INT24:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "mediumint unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "mediumint" );
+ pDescriptorRecord->setConciseType( SQL_INTEGER );
+ break;
+ case MYSQL_TYPE_LONG:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "integer unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "integer" );
+ pDescriptorRecord->setConciseType( SQL_TINYINT );
+ break;
+ case MYSQL_TYPE_LONG_BLOB:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ if (pField->flags & BINARY_FLAG)
+ {
+ pDescriptorRecord->setTypeName( "longblob" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
+ }
+ else
+ {
+ pDescriptorRecord->setTypeName( "longtext" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
+ }
+ break;
+ case MYSQL_TYPE_LONGLONG:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ if ( pField->flags & UNSIGNED_FLAG )
+ {
+ pDescriptorRecord->setPrecision( 20 );
+ pDescriptorRecord->setTypeName( "bigint unsigned" );
+ }
+ else
+ {
+ pDescriptorRecord->setPrecision( 19 );
+ pDescriptorRecord->setTypeName( "bigint" );
+ }
+ pDescriptorRecord->setConciseType( SQL_BIGINT );
+ break;
+ case MYSQL_TYPE_MEDIUM_BLOB:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ if ( pField->flags & BINARY_FLAG )
+ {
+ pDescriptorRecord->setTypeName( "mediumblob" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
+ }
+ else
+ {
+ pDescriptorRecord->setTypeName( "mediumtext" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
+ }
+ break;
+ case MYSQL_TYPE_NEWDATE:
+ pDescriptorRecord->setDisplaySize( 10 );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( 10 );
+ pDescriptorRecord->setTypeName( "date" );
+ pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
+ break;
+ case MYSQL_TYPE_NULL:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setTypeName( "null" );
+ pDescriptorRecord->setConciseType( SQL_VARCHAR );
+ break;
+ case MYSQL_TYPE_SHORT:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "smallint unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "smallint" );
+ pDescriptorRecord->setConciseType( SQL_SMALLINT );
+ break;
+ case MYSQL_TYPE_TIME:
+ pDescriptorRecord->setDisplaySize( 8 );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( 8 );
+ pDescriptorRecord->setTypeName( "time" );
+ pDescriptorRecord->setConciseType( SQL_TYPE_TIME );
+ break;
+ case MYSQL_TYPE_TIMESTAMP:
+ pDescriptorRecord->setDisplaySize( 19 );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( 19 );
+ pDescriptorRecord->setRowver( SQL_TRUE );
+ pDescriptorRecord->setTypeName( "timestamp" );
+ pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
+ break;
+ case MYSQL_TYPE_SET:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setTypeName( "set" );
+ pDescriptorRecord->setConciseType( SQL_CHAR );
+ break;
+ case MYSQL_TYPE_STRING:
+ pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setTypeName( "char" );
+ pDescriptorRecord->setConciseType( SQL_CHAR );
+ break;
+ case MYSQL_TYPE_TINY:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 2 );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ if ( pField->flags & NUM_FLAG )
+ {
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "tinyint unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "tinyint" );
+ pDescriptorRecord->setConciseType( SQL_TINYINT );
+ }
+ else
+ {
+ if ( pField->flags & UNSIGNED_FLAG )
+ pDescriptorRecord->setTypeName( "char unsigned" );
+ else
+ pDescriptorRecord->setTypeName( "char" );
+ pDescriptorRecord->setConciseType( SQL_CHAR );
+ }
+ break;
+ case MYSQL_TYPE_TINY_BLOB:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "" );
+ pDescriptorRecord->setLiteralSuffix( "" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ if ( pField->flags & BINARY_FLAG )
+ {
+ pDescriptorRecord->setTypeName( "tinyblob" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
+ }
+ else
+ {
+ pDescriptorRecord->setTypeName( "tinytext" );
+ pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
+ }
+ break;
+ case MYSQL_TYPE_VAR_STRING:
+ pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setTypeName( "varchar" );
+ pDescriptorRecord->setConciseType( SQL_VARCHAR );
+ break;
+ case MYSQL_TYPE_YEAR:
+ pDescriptorRecord->setLength( pField->max_length );
+ pDescriptorRecord->setLiteralPrefix( "\"'" );
+ pDescriptorRecord->setLiteralSuffix( "\"'" );
+ pDescriptorRecord->setNumPrecRadix( 0 );
+ pDescriptorRecord->setOctetLength( pField->max_length );
+ pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
+ pDescriptorRecord->setTypeName( "year" );
+ pDescriptorRecord->setConciseType( SQL_SMALLINT );
+ break;
+ default:
+ {
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "%1 %2" ).arg( pField->type ).arg( tr(" is an unknown MYSQL column data
type.") ) ) );
+ }
+ }
+
+ MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+
+
+
Modified: MYSQLPlus/MYSQLPlusLib/MResult.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.h 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResult.h 2006-06-02 05:36:39 UTC (rev 311)
@@ -190,6 +190,7 @@
/* doers */
virtual SQLRETURN doStateRollBack( STATE nState ) = 0;
+ SQLRETURN doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField,
MDescriptorIRD *pDescriptor );
private:
STATE nState; /*!< our state
*/
Modified: MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultPlus.cpp 2006-06-02 05:36:39 UTC (rev 311)
@@ -1571,52 +1571,53 @@
SQLRETURN MResultPlus::doAppendColumnsColumns( const QString &stringCatalog, const
QString &stringSchema, const QString &stringTable, const QString
&stringColumnFilter )
{
- SQLCHAR szSQL[1024];
- MYSQL_RES * pResult = NULL;
- MYSQL_FIELD * pField = NULL;
- MYODBC_DES_REC_PTR pDesRec = NULL;
- char szAlpha[100];
- SQLINTEGER nColumn = 1;
+ SQLCHAR szSQL[1024];
+ MYSQL_RES * pResult = NULL;
+ unsigned int nFields;
+ unsigned int nField;
+ MYSQL_FIELD * pField;
+
/*!
\todo
Use given schema.
*/
- sprintf( szSQL, "SELECT * FROM %s.%s LIMIT 0", pszCatalog, pszTable );
+ sprintf( szSQL, "SELECT * FROM %s.%s LIMIT 0", stringCatalog.toAscii().data(),
stringTable.toAscii().data() );
- if ( mysql_query( pStm->pDbc->pMySQL, szSQL ) )
- {
- MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY000, mysql_errno(
pStm->pDbc->pMySQL ), (SQLCHAR*)mysql_error( pStm->pDbc->pMySQL ) );
- MYODBCDbgReturn( SQL_ERROR );
- }
+ if ( mysql_query( getMySQL(), szSQL ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_errno( getMySQL() ), mysql_error( getMySQL() ) ) );
- pResult = mysql_use_result( pStm->pDbc->pMySQL );
+ pResult = mysql_use_result( getMySQL() );
if ( !pResult )
- {
- MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY000, mysql_errno(
pStm->pDbc->pMySQL ), (SQLCHAR*)mysql_error( pStm->pDbc->pMySQL ) );
- MYODBCDbgReturn( SQL_ERROR );
- }
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_errno( getMySQL() ), mysql_error( getMySQL() ) ) );
+ nFields = mysql_num_fields( pRes );
+ if ( !nFields )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("mysql_num_fields() failed to return number of fields") ) );
+
+ MDescriptorIRD descriptor( getStatement() );
+ descriptor.setCount( nFields, true );
+
/*!
\todo
Use given column filter.
*/
- pDesRec = MYODBCDesRecAlloc( MYODBC_RTTI_DES_IRD );
- while ( pField = mysql_fetch_field( pResult ) )
+ for ( nField = 0; nField < nFields; nField++ )
{
- /*
- This is going to seem a bit crazy bit we need to tranlate the
- the MYSQL_FIELD into a descriptor and then map it into the
- result row based upon the mapping detailed in the ODBC
- specification. We also want to use a single function for all
- mapping of MYSQL_FIELD into ODBC details to avoid having
- multiple functions or code blocks getting out of synch.
+ /*!
+ \internal
+ \note
+
+ This is going to seem a bit crazy bit we need to translate the the
MYSQL_FIELD into a descriptor and then map it into the
+ result row based upon the mapping detailed in the ODBC specification. We also
want to use a single function for all
+ mapping of MYSQL_FIELD into ODBC details to avoid having multiple functions
or code blocks getting out of synch.
- So we translate MYLSQ_FIELD into a descriptor and then map
- descriptor into result row.
+ So we translate MYLSQ_FIELD into a descriptor and then map descriptor into
result row.
*/
- MYODBCResStoreMetaDataField( pDesRec, pField );
+ SQLRETURN nReturn = doLoadMetaDataField( nField + 1, mysql_fetch_field_direct(
pRes, nField ), &descriptor );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Failed to store field descriptor information.") ) );
/*!
\todo
@@ -1626,30 +1627,74 @@
- pszColumnSize, pszBufferLength, pszDecimalDigits need another look
- pszColumnDef
*/
- MYODBCDrvAppendColumn( pStm->hRes,
- MYODBCCStrDup( pszCatalog, SQL_NTS ), /* pszTableCat */
- MYODBCCStrDup( pszSchema, SQL_NTS ), /* pszTableSchem */
- MYODBCCStrDup( pDesRec->desc_base_table_name, SQL_NTS
), /* pszTableName */
- MYODBCCStrDup( pDesRec->desc_base_column_name, SQL_NTS
), /* pszColumnName */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_concise_type, szAlpha, 10 ), SQL_NTS ), /* pszDataType */
- MYODBCCStrDup( pDesRec->desc_type_name, SQL_NTS ), /*
pszTypeName */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_display_size, szAlpha, 10 ), SQL_NTS ), /* pszColumnSize */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_display_size, szAlpha, 10 ), SQL_NTS ), /* pszBufferLength */
- MYODBCCStrDup( MYODBCCIntToAlpha( pDesRec->desc_scale,
szAlpha, 10 ), SQL_NTS ), /* pszDecimalDigits */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_num_prec_radix, szAlpha, 10 ), SQL_NTS ), /* pszNumPrecRadix */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_nullable, szAlpha, 10 ), SQL_NTS ), /* pszNullable */
- NULL, /* pszRemarks */
- NULL, /* pszColumnDef */
- MYODBCCStrDup( MYODBCCIntToAlpha( pDesRec->desc_type,
szAlpha, 10 ), SQL_NTS ), /* pszSqlDataType */
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_datetime_interval_code, szAlpha, 10 ), SQL_NTS ), /* pszSqlDateTimeSub
*/
- MYODBCCStrDup( MYODBCCIntToAlpha(
pDesRec->desc_octet_length, szAlpha, 10 ), SQL_NTS ), /* pszCharOctetLength */
- MYODBCCStrDup( MYODBCCIntToAlpha( nColumn, szAlpha, 10 ),
SQL_NTS ), /* pszOrdinalPosition */
- MYODBCCStrDup( ( pDesRec->desc_nullable == SQL_NO_NULLS
? "NO" : "YES" ), SQL_NTS ) /* pszIsNullable */ );
- nColumn++;
- MYODBCDesRecClear( pDesRec );
+ MDescriptorRecord *pDescriptorRecord = descriptor.getRecord( nField + 1 );
+
+ doAppendColumns( pDescriptorRecord->getCatalogName(),
+ pDescriptorRecord->getSchemaName(),
+ pDescriptorRecord->getBaseTableName(),
+ pDescriptorRecord->getBaseColumnName(),
+ pDescriptorRecord->getConciseType(),
+ pDescriptorRecord->getTypeName(),
+ pDescriptorRecord->getDisplaySize(),
+ pDescriptorRecord->getDisplaySize(),
+ pDescriptorRecord->getScale(),
+ pDescriptorRecord->getNumPrecRadix(),
+ pDescriptorRecord->getNullable(),
+ QString::null, /* pszRemarks */
+ QString::null, /* pszColumnDef */
+ pDescriptorRecord->getType(),
+ pDescriptorRecord->getDatetimeIntervalCode(),
+ pDescriptorRecord->getOctetLength(),
+ nField + 1,
+ ( pDescriptorRecord->getNullable() == SQL_NO_NULLS ? "NO" :
"YES" ) );
}
- MYODBCCFree( pDesRec );
mysql_free_result( pResult );
- return SQL_SUCCESS;
+ MYODBCDbgReturn( SQL_SUCCESS );
}
+
+SQLRETURN MResultPlus::doAppendColumns( const QString &stringTableCat,
+ const QString &stringTableSchem,
+ const QString &stringTableName,
+ const QString &stringColumnName,
+ const QString &stringDataType,
+ const QString &stringTypeName,
+ const QString &stringColumnSize,
+ const QString &stringBufferLength,
+ const QString &stringDecimalDigits,
+ const QString &stringNumPrecRadix,
+ const QString &stringNullable,
+ const QString &stringRemarks,
+ const QString &stringColumnDef,
+ const QString &stringSqlDataType,
+ const QString &stringSqlDateTimeSub,
+ const QString &stringCharOctetLength,
+ const QString &stringOrdinalPosition,
+ const QString &stringIsNullable )
+{
+ MYODBCDbgEnter();
+
+ doAppend();
+ setData( 1, stringTableCat );
+ setData( 2, stringTableSchem );
+ setData( 3, stringTableName );
+ setData( 4, stringColumnName );
+ setData( 5, stringDataType );
+ setData( 6, stringTypeName );
+ setData( 7, stringColumnSize );
+ setData( 8, stringBufferLength );
+ setData( 9, stringDecimalDigits );
+ setData( 10, stringNumPrecRadix );
+ setData( 11, stringNullable );
+ setData( 12, stringRemarks );
+ setData( 13, stringColumnDef );
+ setData( 14, stringSqlDataType );
+ setData( 15, stringSqlDateTimeSub );
+ setData( 16, stringCharOctetLength );
+ setData( 17, stringOrdinalPosition );
+ setData( 18, stringIsNullable );
+
+ MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+
Modified: MYSQLPlus/MYSQLPlusLib/MResultPlus.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultPlus.h 2006-06-02 05:36:39 UTC (rev 311)
@@ -161,6 +161,24 @@
SQLRETURN doAppendColumnsSchemas( const QString &stringCatalog, const QString
&stringSchemaFilter, const QString &stringTableFilter, const QString
&stringColumnFilter );
SQLRETURN doAppendColumnsTables( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTableFilter, const QString
&stringColumnFilter );
SQLRETURN doAppendColumnsColumns( const QString &stringCatalog, const QString
&stringSchema, const QString &stringTable, const QString &stringColumnFilter
);
+ SQLRETURN doAppendColumns( const QString &stringTableCat,
+ const QString &stringTableSchem,
+ const QString &stringTableName,
+ const QString &stringColumnName,
+ const QString &stringDataType,
+ const QString &stringTypeName,
+ const QString &stringColumnSize,
+ const QString &stringBufferLength,
+ const QString &stringDecimalDigits,
+ const QString &stringNumPrecRadix,
+ const QString &stringNullable,
+ const QString &stringRemarks,
+ const QString &stringColumnDef,
+ const QString &stringSqlDataType,
+ const QString &stringSqlDateTimeSub,
+ const QString &stringCharOctetLength,
+ const QString &stringOrdinalPosition,
+ const QString &stringIsNullable );
};
#endif
Modified: MYSQLPlus/MYSQLPlusLib/MResultRes.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultRes.cpp 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultRes.cpp 2006-06-02 05:36:39 UTC (rev 311)
@@ -1098,7 +1098,7 @@
for ( nField = 0; nField < nFields; nField++ )
{
pField = mysql_fetch_field_direct( pRes, nField );
- SQLRETURN nReturn = doLoadMetaDataField( nField + 1, pField );
+ SQLRETURN nReturn = doLoadMetaDataField( nField + 1, pField, getImpRowDesc() );
if ( !SQL_SUCCEEDED( nReturn ) )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Failed to store field descriptor information.") ) );
}
@@ -1106,416 +1106,7 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
-/*!
- \brief Appends an IRD record describing the given field.
- This is all about mapping our MySQL field description (MYSQL_FIELD) to our
ODBC
- column description (IRD).
- \param nField
- \param pField
- \return SQLRETURN
-
- \sa doLoadMetaData
-*/
-SQLRETURN MResultRes::doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField )
-{
- MYODBCDbgEnter();
- if ( !pField )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid field structure. Failed to store field descriptor information.") ) );
-
- if ( nField > (unsigned int)getImpRowDesc()->getCount() )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Field index out of range. Failed to store field descriptor information.") ) );
-
- /*
- WARNING!!!
-
- This function needs to be revisited and reviewed - probably several times.
-
- This is a blend of my interpretation (1st pass kind of thing) and what
- is found in the old driver. Some of what is in here is certianly in
- need if some changing.
- */
-
- /*
- common
-
- All fields are included (in alpha order) for completeness. Comments
- are made to state why some are not relevant. Again; there may be
- calculated fields in here which are set now with the thinking that
- it will make maintaining and working with the whole descriptor
- business easier (for example; desc_label which could be just mapped
- to desc_name as needed but is set now).
-
- These must be handled before the type specific ones because in some
- cases the values set here are replaced depending upon the type -
- but only sometimes.
- */
- MDescriptorRecord *pDescriptorRecord = getImpRowDesc()->getRecord( nField );
-
- pDescriptorRecord->setAutoUniqueValue( (pField->flags &&
AUTO_INCREMENT_FLAG) ? SQL_TRUE : SQL_FALSE );
- pDescriptorRecord->setBaseColumnName( (pField->org_name ? pField->org_name :
"") );
- pDescriptorRecord->setBaseTableName( (pField->org_table ? pField->org_table
: "") );
- pDescriptorRecord->setCaseSensitive( (pField->flags & BINARY_FLAG ?
SQL_FALSE : SQL_TRUE) );
- pDescriptorRecord->setCatalogName( (pField->catalog ? pField->catalog : "")
);
-/* pDescriptorRecord->setconcise_type; - type specific */
-/* pDescriptorRecord->setdata_ptr; - N/A */
-/* pDescriptorRecord->setdatetime_interval_code; - type specific */
- pDescriptorRecord->setDatetimeIntervalPrecision( 10 ); /* this is a
conservative guess - not sure what precision we get when we diff 2 times */
- pDescriptorRecord->setDisplaySize( pField->max_length ); /* - also type
specific */
- pDescriptorRecord->setFixedPrecScale( SQL_FALSE ); /* - also type
specific */
-/* pDescriptorRecord->setindicator_ptr; - N/A */
- pDescriptorRecord->setLabel( pField->name );
-/* pDescriptorRecord->setlength; - type specific */
-/* pDescriptorRecord->setliteral_prefix; - type specific */
-/* pDescriptorRecord->setliteral_suffix; - type specific */
- pDescriptorRecord->setLocalTypeName( "" );
- pDescriptorRecord->setName( pField->name );
- pDescriptorRecord->setNullable( ((pField->flags && NOT_NULL_FLAG) ?
SQL_NO_NULLS : SQL_NULLABLE) );
-/* pDescriptorRecord->setnum_prec_radix; - type specific */
-/* pDescriptorRecord->setoctet_length; - type specific */
-/* pDescriptorRecord->setoctet_length_ptr; - N/A */
-/* pDescriptorRecord->setparamter_type; - N/A */
-/* pDescriptorRecord->setprecision; - type specific */
- pDescriptorRecord->setRowver( SQL_FALSE ); /* - also type specific */
- pDescriptorRecord->setScale( pField->decimals );
- pDescriptorRecord->setSchemaName( pField->db );
- pDescriptorRecord->setSearchable( SQL_PRED_SEARCHABLE );
- pDescriptorRecord->setTableName( pField->table );
-/* pDescriptorRecord->settype; - type specific */
-/* pDescriptorRecord->settype_name; - type specific */
- pDescriptorRecord->setUnnamed( SQL_NAMED );
- pDescriptorRecord->setUnsigned( (pField->flags & UNSIGNED_FLAG ? SQL_TRUE :
SQL_FALSE) );
- pDescriptorRecord->setUpdatable( (pField->table && pField->table[0]
? SQL_ATTR_READWRITE_UNKNOWN : SQL_ATTR_READONLY) );
-
- /*
- set type specific values here
-
- All supported mysql field types in *alpha* order (for readability).
-
- Many descriptor fields can be set without much regard to the type
- or are may not even be used given that we are an IRD.
-
- The ones set in this switch/case are special cases where the
- values are dependent upon the type. Note that MYODBCDesRecType
- does set some related fields in the descriptor to ensure that
- the related fields are valid.
- */
- switch ( pField->type )
- {
- case MYSQL_TYPE_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setTypeName( "blob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setTypeName( "text" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_DATE:
- pDescriptorRecord->setDisplaySize( 10 );
- pDescriptorRecord->setLength( 10 );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 10 );
- pDescriptorRecord->setTypeName( "date" );
- pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
- break;
- case MYSQL_TYPE_DATETIME:
- pDescriptorRecord->setDisplaySize( 19 );
- pDescriptorRecord->setLength( 19 );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setTypeName( "datetime" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
- break;
- case MYSQL_TYPE_DECIMAL:
- pDescriptorRecord->setDisplaySize( max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
- pDescriptorRecord->setFixedPrecScale( pField->decimals ? SQL_TRUE :
SQL_FALSE );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 10 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
- pDescriptorRecord->setTypeName( "decimal" );
- pDescriptorRecord->setConciseType( SQL_DECIMAL );
- break;
- case MYSQL_TYPE_DOUBLE:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "double unsigned" );
- else
- pDescriptorRecord->setTypeName( "double" );
- pDescriptorRecord->setConciseType( SQL_DOUBLE );
- break;
- case MYSQL_TYPE_ENUM:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "enum" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_FLOAT:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "float unsigned" );
- else
- pDescriptorRecord->setTypeName( "float" );
- pDescriptorRecord->setConciseType( SQL_REAL );
- break;
- case MYSQL_TYPE_GEOMETRY:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "blob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- break;
- case MYSQL_TYPE_INT24:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "mediumint unsigned" );
- else
- pDescriptorRecord->setTypeName( "mediumint" );
- pDescriptorRecord->setConciseType( SQL_INTEGER );
- break;
- case MYSQL_TYPE_LONG:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "integer unsigned" );
- else
- pDescriptorRecord->setTypeName( "integer" );
- pDescriptorRecord->setConciseType( SQL_TINYINT );
- break;
- case MYSQL_TYPE_LONG_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if (pField->flags & BINARY_FLAG)
- {
- pDescriptorRecord->setTypeName( "longblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "longtext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_LONGLONG:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- if ( pField->flags & UNSIGNED_FLAG )
- {
- pDescriptorRecord->setPrecision( 20 );
- pDescriptorRecord->setTypeName( "bigint unsigned" );
- }
- else
- {
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setTypeName( "bigint" );
- }
- pDescriptorRecord->setConciseType( SQL_BIGINT );
- break;
- case MYSQL_TYPE_MEDIUM_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setTypeName( "mediumblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "mediumtext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_NEWDATE:
- pDescriptorRecord->setDisplaySize( 10 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 10 );
- pDescriptorRecord->setTypeName( "date" );
- pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
- break;
- case MYSQL_TYPE_NULL:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setTypeName( "null" );
- pDescriptorRecord->setConciseType( SQL_VARCHAR );
- break;
- case MYSQL_TYPE_SHORT:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "smallint unsigned" );
- else
- pDescriptorRecord->setTypeName( "smallint" );
- pDescriptorRecord->setConciseType( SQL_SMALLINT );
- break;
- case MYSQL_TYPE_TIME:
- pDescriptorRecord->setDisplaySize( 8 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 8 );
- pDescriptorRecord->setTypeName( "time" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIME );
- break;
- case MYSQL_TYPE_TIMESTAMP:
- pDescriptorRecord->setDisplaySize( 19 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setRowver( SQL_TRUE );
- pDescriptorRecord->setTypeName( "timestamp" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
- break;
- case MYSQL_TYPE_SET:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "set" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_STRING:
- pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "char" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_TINY:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & NUM_FLAG )
- {
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "tinyint unsigned" );
- else
- pDescriptorRecord->setTypeName( "tinyint" );
- pDescriptorRecord->setConciseType( SQL_TINYINT );
- }
- else
- {
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "char unsigned" );
- else
- pDescriptorRecord->setTypeName( "char" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- }
- break;
- case MYSQL_TYPE_TINY_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setTypeName( "tinyblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "tinytext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_VAR_STRING:
- pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "varchar" );
- pDescriptorRecord->setConciseType( SQL_VARCHAR );
- break;
- case MYSQL_TYPE_YEAR:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- pDescriptorRecord->setTypeName( "year" );
- pDescriptorRecord->setConciseType( SQL_SMALLINT );
- break;
- default:
- {
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "%1 %2" ).arg( pField->type ).arg( tr(" is an unknown MYSQL column data
type.") ) ) );
- }
- }
-
- MYODBCDbgReturn( SQL_SUCCESS );
-}
-
-
-
-
Modified: MYSQLPlus/MYSQLPlusLib/MResultRes.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultRes.h 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultRes.h 2006-06-02 05:36:39 UTC (rev 311)
@@ -65,7 +65,6 @@
/* doers */
SQLRETURN doRefresh();
SQLRETURN doLoadMetaData(); /* load resultset meta data (IRD)
*/
- SQLRETURN doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField ); /* load
resultset column meta data (IRD) */
};
#endif
Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-06-02 05:36:39 UTC (rev 311)
@@ -1246,7 +1246,7 @@
for ( nField = 0; nField < nFields; nField++ )
{
pField = mysql_fetch_field( pMetaData );
- SQLRETURN nReturn = doLoadMetaDataField( nField + 1, pField );
+ SQLRETURN nReturn = doLoadMetaDataField( nField + 1, pField, getImpRowDesc()
);
if ( !SQL_SUCCEEDED( nReturn ) )
{
mysql_free_result( pMetaData );
@@ -1270,416 +1270,4 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
-/*!
- \brief Appends an IRD record describing the given field.
- This is all about mapping our MySQL field description (MYSQL_FIELD) to our
ODBC
- column description (IRD).
-
- \param nField
- \param pField
-
- \return SQLRETURN
-
- \sa doLoadMetaData
-*/
-SQLRETURN MResultStmt::doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField )
-{
- MYODBCDbgEnter();
-
- if ( !pField )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid field structure. Failed to store field descriptor information.") ) );
-
- if ( nField > (unsigned int)getImpRowDesc()->getCount() )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Field index out of range. Failed to store field descriptor information.") ) );
-
- /*
- WARNING!!!
-
- This function needs to be revisited and reviewed - probably several times.
-
- This is a blend of my interpretation (1st pass kind of thing) and what
- is found in the old driver. Some of what is in here is certianly in
- need if some changing.
- */
-
- /*
- common
-
- All fields are included (in alpha order) for completeness. Comments
- are made to state why some are not relevant. Again; there may be
- calculated fields in here which are set now with the thinking that
- it will make maintaining and working with the whole descriptor
- business easier (for example; desc_label which could be just mapped
- to desc_name as needed but is set now).
-
- These must be handled before the type specific ones because in some
- cases the values set here are replaced depending upon the type -
- but only sometimes.
- */
- MDescriptorRecord *pDescriptorRecord = getImpRowDesc()->getRecord( nField );
-
- pDescriptorRecord->setAutoUniqueValue( (pField->flags &&
AUTO_INCREMENT_FLAG) ? SQL_TRUE : SQL_FALSE );
- pDescriptorRecord->setBaseColumnName( (pField->org_name ? pField->org_name :
"") );
- pDescriptorRecord->setBaseTableName( (pField->org_table ? pField->org_table
: "") );
- pDescriptorRecord->setCaseSensitive( (pField->flags & BINARY_FLAG ?
SQL_FALSE : SQL_TRUE) );
- pDescriptorRecord->setCatalogName( (pField->catalog ? pField->catalog : "")
);
-/* pDescriptorRecord->setconcise_type; - type specific */
-/* pDescriptorRecord->setdata_ptr; - N/A */
-/* pDescriptorRecord->setdatetime_interval_code; - type specific */
- pDescriptorRecord->setDatetimeIntervalPrecision( 10 ); /* this is a
conservative guess - not sure what precision we get when we diff 2 times */
- pDescriptorRecord->setDisplaySize( pField->max_length ); /* - also type
specific */
- pDescriptorRecord->setFixedPrecScale( SQL_FALSE ); /* - also type
specific */
-/* pDescriptorRecord->setindicator_ptr; - N/A */
- pDescriptorRecord->setLabel( pField->name );
-/* pDescriptorRecord->setlength; - type specific */
-/* pDescriptorRecord->setliteral_prefix; - type specific */
-/* pDescriptorRecord->setliteral_suffix; - type specific */
- pDescriptorRecord->setLocalTypeName( "" );
- pDescriptorRecord->setName( pField->name );
- pDescriptorRecord->setNullable( ((pField->flags && NOT_NULL_FLAG) ?
SQL_NO_NULLS : SQL_NULLABLE) );
-/* pDescriptorRecord->setnum_prec_radix; - type specific */
-/* pDescriptorRecord->setoctet_length; - type specific */
-/* pDescriptorRecord->setoctet_length_ptr; - N/A */
-/* pDescriptorRecord->setparamter_type; - N/A */
-/* pDescriptorRecord->setprecision; - type specific */
- pDescriptorRecord->setRowver( SQL_FALSE ); /* - also type specific */
- pDescriptorRecord->setScale( pField->decimals );
- pDescriptorRecord->setSchemaName( pField->db );
- pDescriptorRecord->setSearchable( SQL_PRED_SEARCHABLE );
- pDescriptorRecord->setTableName( pField->table );
-/* pDescriptorRecord->settype; - type specific */
-/* pDescriptorRecord->settype_name; - type specific */
- pDescriptorRecord->setUnnamed( SQL_NAMED );
- pDescriptorRecord->setUnsigned( (pField->flags & UNSIGNED_FLAG ? SQL_TRUE :
SQL_FALSE) );
- pDescriptorRecord->setUpdatable( (pField->table && pField->table[0]
? SQL_ATTR_READWRITE_UNKNOWN : SQL_ATTR_READONLY) );
-
- /*
- set type specific values here
-
- All supported mysql field types in *alpha* order (for readability).
-
- Many descriptor fields can be set without much regard to the type
- or are may not even be used given that we are an IRD.
-
- The ones set in this switch/case are special cases where the
- values are dependent upon the type. Note that MYODBCDesRecType
- does set some related fields in the descriptor to ensure that
- the related fields are valid.
- */
- switch ( pField->type )
- {
- case MYSQL_TYPE_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setTypeName( "blob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setTypeName( "text" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_DATE:
- pDescriptorRecord->setDisplaySize( 10 );
- pDescriptorRecord->setLength( 10 );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 10 );
- pDescriptorRecord->setTypeName( "date" );
- pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
- break;
- case MYSQL_TYPE_DATETIME:
- pDescriptorRecord->setDisplaySize( 19 );
- pDescriptorRecord->setLength( 19 );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setTypeName( "datetime" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
- break;
- case MYSQL_TYPE_DECIMAL:
- pDescriptorRecord->setDisplaySize( max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
- pDescriptorRecord->setFixedPrecScale( pField->decimals ? SQL_TRUE :
SQL_FALSE );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 10 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)max( pField->length,
pField->max_length ) - test( !( pField->flags & UNSIGNED_FLAG ) ) - test(
pField->decimals ) );
- pDescriptorRecord->setTypeName( "decimal" );
- pDescriptorRecord->setConciseType( SQL_DECIMAL );
- break;
- case MYSQL_TYPE_DOUBLE:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "double unsigned" );
- else
- pDescriptorRecord->setTypeName( "double" );
- pDescriptorRecord->setConciseType( SQL_DOUBLE );
- break;
- case MYSQL_TYPE_ENUM:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "enum" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_FLOAT:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "float unsigned" );
- else
- pDescriptorRecord->setTypeName( "float" );
- pDescriptorRecord->setConciseType( SQL_REAL );
- break;
- case MYSQL_TYPE_GEOMETRY:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "blob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- break;
- case MYSQL_TYPE_INT24:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "mediumint unsigned" );
- else
- pDescriptorRecord->setTypeName( "mediumint" );
- pDescriptorRecord->setConciseType( SQL_INTEGER );
- break;
- case MYSQL_TYPE_LONG:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "integer unsigned" );
- else
- pDescriptorRecord->setTypeName( "integer" );
- pDescriptorRecord->setConciseType( SQL_TINYINT );
- break;
- case MYSQL_TYPE_LONG_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if (pField->flags & BINARY_FLAG)
- {
- pDescriptorRecord->setTypeName( "longblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "longtext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_LONGLONG:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- if ( pField->flags & UNSIGNED_FLAG )
- {
- pDescriptorRecord->setPrecision( 20 );
- pDescriptorRecord->setTypeName( "bigint unsigned" );
- }
- else
- {
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setTypeName( "bigint" );
- }
- pDescriptorRecord->setConciseType( SQL_BIGINT );
- break;
- case MYSQL_TYPE_MEDIUM_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setTypeName( "mediumblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "mediumtext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_NEWDATE:
- pDescriptorRecord->setDisplaySize( 10 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 10 );
- pDescriptorRecord->setTypeName( "date" );
- pDescriptorRecord->setConciseType( SQL_TYPE_DATE );
- break;
- case MYSQL_TYPE_NULL:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setTypeName( "null" );
- pDescriptorRecord->setConciseType( SQL_VARCHAR );
- break;
- case MYSQL_TYPE_SHORT:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "smallint unsigned" );
- else
- pDescriptorRecord->setTypeName( "smallint" );
- pDescriptorRecord->setConciseType( SQL_SMALLINT );
- break;
- case MYSQL_TYPE_TIME:
- pDescriptorRecord->setDisplaySize( 8 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 8 );
- pDescriptorRecord->setTypeName( "time" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIME );
- break;
- case MYSQL_TYPE_TIMESTAMP:
- pDescriptorRecord->setDisplaySize( 19 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( 19 );
- pDescriptorRecord->setRowver( SQL_TRUE );
- pDescriptorRecord->setTypeName( "timestamp" );
- pDescriptorRecord->setConciseType( SQL_TYPE_TIMESTAMP );
- break;
- case MYSQL_TYPE_SET:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "set" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_STRING:
- pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "char" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- break;
- case MYSQL_TYPE_TINY:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 2 );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- if ( pField->flags & NUM_FLAG )
- {
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "tinyint unsigned" );
- else
- pDescriptorRecord->setTypeName( "tinyint" );
- pDescriptorRecord->setConciseType( SQL_TINYINT );
- }
- else
- {
- if ( pField->flags & UNSIGNED_FLAG )
- pDescriptorRecord->setTypeName( "char unsigned" );
- else
- pDescriptorRecord->setTypeName( "char" );
- pDescriptorRecord->setConciseType( SQL_CHAR );
- }
- break;
- case MYSQL_TYPE_TINY_BLOB:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "" );
- pDescriptorRecord->setLiteralSuffix( "" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- if ( pField->flags & BINARY_FLAG )
- {
- pDescriptorRecord->setTypeName( "tinyblob" );
- pDescriptorRecord->setConciseType( SQL_LONGVARBINARY );
- }
- else
- {
- pDescriptorRecord->setTypeName( "tinytext" );
- pDescriptorRecord->setConciseType( SQL_LONGVARCHAR );
- }
- break;
- case MYSQL_TYPE_VAR_STRING:
- pDescriptorRecord->setDisplaySize( pField->length ? pField->length :
255 );
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setTypeName( "varchar" );
- pDescriptorRecord->setConciseType( SQL_VARCHAR );
- break;
- case MYSQL_TYPE_YEAR:
- pDescriptorRecord->setLength( pField->max_length );
- pDescriptorRecord->setLiteralPrefix( "\"'" );
- pDescriptorRecord->setLiteralSuffix( "\"'" );
- pDescriptorRecord->setNumPrecRadix( 0 );
- pDescriptorRecord->setOctetLength( pField->max_length );
- pDescriptorRecord->setPrecision( (SQLSMALLINT)pField->max_length );
- pDescriptorRecord->setTypeName( "year" );
- pDescriptorRecord->setConciseType( SQL_SMALLINT );
- break;
- default:
- {
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "%1 %2" ).arg( pField->type ).arg( tr(" is an unknown MYSQL column data
type.") ) ) );
- }
- }
-
- MYODBCDbgReturn( SQL_SUCCESS );
-}
-
-
-
-
Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.h 2006-06-02 03:13:45 UTC (rev 310)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.h 2006-06-02 05:36:39 UTC (rev 311)
@@ -98,7 +98,6 @@
/* for some types we have had to use our own data buffer. for example mysql knows
nothing about SQL_NUMERIC_STRUCT - this is freed in here */
// SQLRETURN doFiniBindCol( MYODBC_BIND_COL *pbind );
SQLRETURN doLoadMetaData(); /* load resultset meta data (IRD)
*/
- SQLRETURN doLoadMetaDataField( unsigned int nField, MYSQL_FIELD *pField ); /* load
resultset column meta data (IRD) */
};
#endif
| Thread |
|---|
| • Connector/ODBC 5 commit: r311 - MYSQLPlus/MYSQLPlusLib | pharvey | 2 Jun |