Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:22:03

0001 // $Id: MySQLResultSetMetaData.cxx,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
0002 //*-- Author : Valeriy Onuchin 26/02/2001
0003 //
0004 // RDBC driver to MySQL database implemented with MySQL C API.
0005 //
0006 // ++ The code consists of some parts stolen from "mm JDBC" and  
0007 //    "MyODBC ODBC" drivers and other mysql-related open sources.
0008 //
0009 
0010 ////////////////////////////////////////////////////////////////////
0011 //
0012 // An object that can be used to find out about the 
0013 // types and properties of the columns in a TSQLResultSet. 
0014 //
0015 // See also:
0016 //    TSQLResultSet TSQLDatabaseMetaData
0017 //
0018 ////////////////////////////////////////////////////////////////////
0019    
0020 #include <RDBC/TSQLResultSetMetaData.h>
0021 #include <RDBC/TSQLResultSet.h>
0022 #include "MySQLResultSetPrivate.h"
0023 
0024 ClassImpQ(TSQLResultSetMetaData)
0025 
0026 
0027 ///////////////////////////////////////////////////////////////////// 
0028 //___________________________________________________________________   
0029 TSQLResultSetMetaData::TSQLResultSetMetaData( TSQLResultSet* rs,
0030                                               void* imp ):TSQL(imp)
0031 {
0032    // ctor  
0033    
0034    fResultSet = rs;
0035 
0036    // initiate some structures in  MySQLResultSetPrivate* imp
0037 
0038    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0039    Int_t cols = imp->fMYSQL_RES->field_count;
0040 
0041    imp->fColumnPrecisions = new Int_t[cols];
0042    imp->fColumnTypes = new Int_t[cols];
0043    imp->fColumnTypeNames = new TString[cols];
0044 
0045    for(int i=0; i<cols; i++) {
0046       imp->fColumnPrecisions[i] = max(imp->fMYSQL_RES->fields[i].length, imp->fMYSQL_RES->fields[i].max_length);
0047 
0048       switch(imp->fMYSQL_RES->fields[i].type) {
0049       case FIELD_TYPE_DECIMAL: 
0050          imp->fColumnTypes[i] = kDECIMAL;
0051          imp->fColumnTypeNames[i] = "decimal";
0052          break;
0053       case FIELD_TYPE_CHAR:
0054          imp->fColumnTypeNames[i] = "tinyint";
0055          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0056          imp->fColumnTypes[i] = kTINYINT;
0057          break;
0058       case FIELD_TYPE_SHORT:
0059          imp->fColumnTypeNames[i] = "smallint";
0060          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0061          imp->fColumnTypes[i] = kSMALLINT;
0062          break;
0063       case FIELD_TYPE_INT24:
0064          imp->fColumnTypeNames[i] = "mediumint";
0065          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0066          imp->fColumnTypes[i] = kINTEGER;
0067          break;
0068       case FIELD_TYPE_LONG:
0069          imp->fColumnTypeNames[i] = "integer";
0070          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0071          imp->fColumnTypes[i] = kINTEGER;
0072          break;
0073       case FIELD_TYPE_LONGLONG:
0074          imp->fColumnTypeNames[i] = "bigint";
0075          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0076          imp->fColumnTypes[i] = ? kINTEGER : kBIGINT;
0077 !!    return (stmt->dbc->flag & FLAG_NO_BIGINT) 
0078       case FIELD_TYPE_FLOAT:
0079          imp->fColumnTypeNames[i] = "float";
0080          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0081          imp->fColumnTypes[i] = kREAL;
0082          break;
0083       case FIELD_TYPE_DOUBLE:
0084          imp->fColumnTypeNames[i] = "double";
0085          if(imp->fMYSQL_RES->fields[i].flags & UNSIGNED_FLAG) imp->fColumnTypeNames[i] += " unsigned";
0086          imp->fColumnTypes[i] = kDOUBLE;
0087          break;
0088       case FIELD_TYPE_NULL:
0089          imp->fColumnTypeNames[i] = "null";
0090          imp->fColumnTypes[i] = kVARCHAR;
0091          break;
0092       case FIELD_TYPE_YEAR:
0093          imp->fColumnTypeNames[i] = "year";
0094          imp->fColumnTypes[i] = kSMALLINT;
0095          break;
0096       case FIELD_TYPE_TIMESTAMP:
0097          imp->fColumnTypeNames[i] = "timestamp";
0098          imp->fColumnPrecisions[i] = 19;
0099          imp->fColumnTypes[i] = kTIMESTAMP;
0100          break;
0101       case FIELD_TYPE_DATETIME:
0102          imp->fColumnTypeNames[i] = "datetime";
0103          imp->fColumnPrecisions[i] =  = 19;
0104          imp->fColumnTypes[i] = kTIMESTAMP;
0105          break;
0106       case FIELD_TYPE_NEWDATE:
0107       case FIELD_TYPE_DATE:
0108          imp->fColumnTypeNames[i] = "date";
0109          imp->fColumnPrecisions[i] = 10;
0110          imp->fColumnTypes[i] = kDATE;
0111          break;
0112       case FIELD_TYPE_TIME:
0113          imp->fColumnTypeNames[i] = "time";
0114          imp->fColumnPrecisions[i] = 8;
0115          imp->fColumnTypes[i] = kTIME;
0116          break;
0117       case FIELD_TYPE_STRING:
0118          imp->fColumnTypeNames[i] = "char";
0119          imp->fColumnTypes[i] = kCHAR;
0120          break;
0121       case FIELD_TYPE_VAR_STRING:
0122          imp->fColumnTypeNames[i] = "varchar";
0123          imp->fColumnTypes[i] = kVARCHAR;
0124          break;
0125       case FIELD_TYPE_TINY_BLOB:
0126          imp->fColumnTypeNames[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? "tinyblob" : "tinytext");
0127          if (stmt->dbc->flag & (FLAG_FIELD_LENGTH | FLAG_SAFE)) imp->fColumnPrecisions[i] = 255;
0128          imp->fColumnTypes[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? kLONGVARBINARY : kLONGVARCHAR;
0129       case FIELD_TYPE_BLOB:
0130          imp->fColumnTypeNames[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? "blob" : "text");
0131          if (stmt->dbc->flag & (FLAG_FIELD_LENGTH | FLAG_SAFE))  imp->fColumnPrecisions[i] = 65535;
0132          imp->fColumnTypes[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? kLONGVARBINARY : kLONGVARCHAR;
0133       case FIELD_TYPE_MEDIUM_BLOB:
0134          imp->fColumnTypeNames[i] = ((imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? "mediumblob" : "mediumtext"));
0135          if (stmt->dbc->flag & (FLAG_FIELD_LENGTH | FLAG_SAFE))imp->fColumnPrecisions[i] = (1L << 24)-1L;
0136          imp->fColumnTypes[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? kLONGVARBINARY : kLONGVARCHAR;
0137       case FIELD_TYPE_LONG_BLOB:
0138          imp->fColumnTypeNames[i] = ((imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? "longblob": "longtext"));
0139          if (stmt->dbc->flag & (FLAG_FIELD_LENGTH | FLAG_SAFE)) imp->fColumnPrecisions[i] = = INT_MAX32;
0140          imp->fColumnTypes[i] = (imp->fMYSQL_RES->fields[i].flags & BINARY_FLAG) ? kLONGVARBINARY : kLONGVARCHAR;
0141       case FIELD_TYPE_ENUM:
0142          imp->fColumnTypeNames[i] = "enum";
0143          imp->fColumnTypes[i] = kCHAR;
0144          break;
0145       case FIELD_TYPE_SET:
0146          imp->fColumnTypeNames[i] = "set";
0147          imp->fColumnTypes[i] = kCHAR;
0148          break;
0149       }
0150    } 
0151 }
0152 
0153 //___________________________________________________________________
0154 TSQLResultSetMetaData::~TSQLResultSetMetaData()
0155 {
0156    // dtor  
0157 
0158    fResultSet = 0;
0159    fImp = 0;
0160 }
0161                          
0162 //___________________________________________________________________
0163 Int_t TSQLResultSetMetaData::GetColumnCount()
0164 {                   
0165    // Returns the number of columns in this TSQLResultSet
0166    // If there are no columns in the result set, zero is
0167    // returned.
0168    //
0169    //  Returns:
0170    //       the number of columns
0171    //  Throws:
0172    //       TSQLException - if a database access error occurs
0173 
0174    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0175    return (imp->fMYSQL_RES->field_count);
0176 }
0177 
0178 //___________________________________________________________________
0179 Bool_t TSQLResultSetMetaData::IsAutoIncrement( Int_t column )
0180 {                       
0181    // Indicates whether the column is automatically numbered, 
0182    // thus read-only.
0183    //
0184    //  Parameters:
0185    //       column - the first column is 1, the second is 2, ...
0186    //  Returns:
0187    //       kTRUE - the column's data type is an auto increment data
0188    //               type
0189    //       kFALSE - the  column's data type is not an auto increment
0190    //                data type or the column does not contain numeric 
0191    //                data
0192    //  Throws:
0193    //       TSQLException - if a database access error occurs
0194 
0195    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0196 
0197    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0198       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0199       return kFALSE;
0200    }
0201 
0202    return (imp->MYSQL_RES->fields[column-1].flags & AUTO_INCREMENT_FLAG);
0203 }
0204 
0205 //___________________________________________________________________
0206 Bool_t TSQLResultSetMetaData::IsCaseSensitive( Int_t column )
0207 {                        
0208    // Indicates whether a column's case sensitive for collations
0209    // and comparisons.
0210    //
0211    //  Parameters:
0212    //       column - the first column is 1, the second is 2, ...
0213    //  Returns:
0214    //       kTRUE if so
0215    //  Throws:
0216    //       TSQLException - if a database access error occurs
0217 
0218    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0219    
0220    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0221       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0222       return kFALSE;
0223    }
0224 
0225    return (imp->MYSQL_RES->fields[column-1].flags & BINARY_FLAG); // true if not binary
0226 }
0227 
0228 //___________________________________________________________________
0229 Bool_t TSQLResultSetMetaData::IsSearchable( Int_t column )                     
0230 {
0231    // Indicates whether the column can be used in a 'WHERE' clause.
0232    //
0233    //  Parameters:
0234    //       column - the first column is 1, the second is 2, ...
0235    //  Returns:
0236    //       kTRUE if so
0237    //  Throws:
0238    //       TSQLException - if a database access error occurs
0239 
0240    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0241 
0242    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0243       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0244       return kFALSE;
0245    }
0246 
0247    return kTRUE;  // MyODBC always returns SQL_SEARCHABLE
0248 }
0249 
0250 //___________________________________________________________________
0251 Bool_t TSQLResultSetMetaData::IsCurrency( Int_t column )
0252 {
0253    // Indicates whether the column is a cash value ( money data type ).
0254    //
0255    //  Parameters:
0256    //       column - the first column is 1, the second is 2, ...
0257    //  Returns:
0258    //       kTRUE if so
0259    //  Throws:
0260    //       TSQLException - if a database access error occurs
0261 
0262    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0263 
0264    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0265       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0266       return kFALSE;
0267    }
0268 
0269    return kFALSE; // MyODBC always returns 0
0270 }
0271 
0272 //___________________________________________________________________
0273 Bool_t TSQLResultSetMetaData::IsNullable( Int_t column )               
0274 {
0275    // Indicates the nullability of values in the designated column.
0276    //
0277    //  Parameters:
0278    //       column - the first column is 1, the second is 2, ...
0279    //  Returns:
0280    //       the nullability status of the given column; 
0281    //       one of columnNoNulls, columnNullable or 
0282    //       columnNullableUnknown
0283    //  Throws:
0284    //       TSQLException - if a database access error occurs
0285 
0286    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0287 
0288    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0289       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0290       return kFALSE;
0291    }
0292    
0293    return ((imp->MYSQL_RES->fields[column-1].flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) != NOT_NULL_FLAG);
0294 }
0295 
0296 //___________________________________________________________________
0297 Bool_t TSQLResultSetMetaData::IsSigned( Int_t column )                 
0298 {
0299    // Indicates whether values in the column are signed numbers
0300    //
0301    //  Parameters:
0302    //       column - the first column is 1, the second is 2, ...
0303    //  Returns:
0304    //       kTRUE if so
0305    //  Throws:
0306    //       TSQLException - if a database access error occurs
0307 
0308    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0309 
0310    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0311       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0312       return kFALSE;
0313    }
0314 
0315    retrurn !(imp->MYSQL_RES->fields[column-1].flags & UNSIGNED_FLAG);  
0316 }
0317 
0318 //___________________________________________________________________
0319 Int_t TSQLResultSetMetaData::GetColumnDisplaySize( Int_t column )
0320 {                         
0321    // Indicates the column's normal max width in chars.
0322    //
0323    //  Parameters:
0324    //       column - the first column is 1, the second is 2, ...
0325    //  Returns:
0326    //       the normal maximum number of characteimp allowed as 
0327    //       the width of the designated column
0328    //  Throws:
0329    //       TSQLException - if a database access error occurs
0330 
0331    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0332 
0333    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0334       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0335       return 0;
0336    }
0337 
0338    return imp->fColumnPrecisions[column-1];
0339 }
0340 
0341 //___________________________________________________________________
0342 TString TSQLResultSetMetaData::GetColumnLabel( Int_t column )
0343 {         
0344    // Gets the suggested column title for use in printouts 
0345    // and displays.
0346    //
0347    //  Parameters:
0348    //       column - the first column is 1, the second is 2, ...
0349    //  Returns:
0350    //       the suggested column title
0351    //  Throws:
0352    //       TSQLException - if a database access error occurs
0353 
0354    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0355 
0356    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0357       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0358       return "";
0359    }
0360 
0361    return imp->MYSQL_RES->fields[column-1].name;
0362 }
0363 
0364 //___________________________________________________________________
0365 TString TSQLResultSetMetaData::GetColumnName( Int_t column )
0366 {                     
0367    // Gets a column's name.
0368    //
0369    //   Parameters:
0370    //        column - the first column is 1, the second is 2, ...
0371    //   Returns:
0372    //        column name
0373    //   Throws:
0374    //        TSQLException - if a database access error occurs
0375 
0376    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0377 
0378    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0379       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0380       return "";
0381    }
0382 
0383    return imp->MYSQL_RES->fields[column-1].name;
0384 }
0385 
0386 //___________________________________________________________________
0387 TString TSQLResultSetMetaData::GetSchemaName( Int_t column )
0388 {                     
0389    // Gets a column's table's schema.
0390    //
0391    //  Parameters:
0392    //       column - the first column is 1, the second is 2, ...
0393    //  Returns:
0394    //       schema name or "" if not applicable
0395    //  Throws:
0396    //       TSQLException - if a database access error occurs
0397 
0398    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0399 
0400    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0401       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0402       return "";
0403    }
0404 
0405    return "";  // do it like MyODBC, i.e. return nothing  ...
0406 }
0407 
0408 //___________________________________________________________________
0409 Int_t TSQLResultSetMetaData::GetPrecision( Int_t column )
0410 {  
0411    // Gets a column's number of decimal digits.
0412    //
0413    //  Parameters:
0414    //       column - the first column is 1, the second is 2, ...
0415    //  Returns:
0416    //       precIsion
0417    //  Throws:
0418    //       TSQLException - if a database access error occurs
0419 
0420    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0421 
0422    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0423       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0424       return 0;
0425    }
0426 
0427    return imp->fColumnPrecisions[column-1];
0428 }
0429 
0430 //___________________________________________________________________
0431 Int_t TSQLResultSetMetaData::GetScale( Int_t column )             
0432 {
0433    // Gets a column's number of digits to right of the decimal point.
0434    //
0435    //  Parameters:
0436    //       column - the first column is 1, the second is 2, ...
0437    //  Returns:
0438    //       scale
0439    //  Throws:
0440    //       TSQLException - if a database access error occurs
0441 
0442    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0443 
0444    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0445       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0446       return 0;
0447    }
0448 
0449    return (imp->MYSQL_RES->fields[column-1].decimals);
0450 }
0451 
0452 //___________________________________________________________________
0453 TString TSQLResultSetMetaData::GetTableName( Int_t column )
0454 {                    
0455    // Gets a column's table name.
0456    //
0457    //  Parameters:
0458    //       column - the first column is 1, the second is 2, ...
0459    //  Returns:
0460    //       table name or "" if not applicable
0461    //  Throws:
0462    //       TSQLException - if a database access error occurs
0463 
0464    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0465 
0466    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0467       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0468       return ("");
0469    }
0470 
0471    return (imp->MYSQL_RES->fields[column-1].table ? imp->MYSQL_RES->fields[column-1].table : ""); 
0472 }
0473 
0474 //___________________________________________________________________
0475 TString TSQLResultSetMetaData::GetCatalogName( Int_t column )
0476 {                      
0477    // Gets a column's table's catalog name.
0478    //
0479    //  Parameters:
0480    //       column - the first column is 1, the second is 2, ...
0481    //  Returns:
0482    //       column name or "" if not applicable.
0483    //  Throws:
0484    //       TSQLException - if a database access error occurs
0485 
0486    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0487 
0488    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0489       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0490       return "";
0491    }
0492 
0493    return "";  // do it like MyODBC, i.e.return nothing  ( could be retrived from TSQLStatement ) 
0494 }
0495 
0496 //___________________________________________________________________
0497 Int_t TSQLResultSetMetaData::GetColumnType( Int_t column )
0498 {                  
0499    // Retrieves a column's SQL type. 
0500    //
0501    // enum ESQLTypes { 
0502    //       kBIGINT = -5,
0503    //       kBINARY = -2,
0504    //       kBIT = -7,
0505    //       kCHAR = 1,
0506    // #ifdef ODBC_VER_LESS_30 
0507    //       kDATE = 9,
0508    //       kTIME = 10,
0509    //       kTIMESTAMP = 11,
0510    // #endif     
0511    //       kDATE = 91,
0512    //       kTIME = 92,
0513    //       kTIMESTAMP = 93,
0514    //       kSMALLINT = 5,
0515    //       kDECIMAL = 3,
0516    //       kDOUBLE = 8,
0517    //       kFLOAT = 6,
0518    //       kINTEGER = 4,
0519    //       kLONGVARBINARY = -4,
0520    //       kLONGVARCHAR = -1,
0521    //       kNUMERIC = 2,
0522    //       kREAL = 7,
0523    //       kTINYINT = -6,
0524    //       kVARBINARY = -3,
0525    //       kVARCHAR  = 12 
0526    // };
0527    //   
0528    // Parameters:
0529    //       column - the first column is 1, the second is 2, ...
0530    //  Returns:
0531    //       SQL type from TSQLTypes
0532    //  Throws:
0533    //       TSQLException - if a database access error occurs
0534 
0535    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0536 
0537    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0538       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0539       return 0;
0540    }
0541 
0542    return imp->fColumnTypes[column-1];
0543 }
0544 
0545 //___________________________________________________________________
0546 TString TSQLResultSetMetaData::GetColumnTypeName( Int_t column )
0547 {
0548    // Retrieves a column's database-specific type name.
0549    // See TSQLTypes.h
0550    //
0551    //  Parameters:
0552    //       column - the first column is 1, the second is 2, ...
0553    //  Returns:
0554    //       type name used by the database. If the column type is 
0555    //       a user-defined type, then a fully-qualified type name 
0556    //       is returned.
0557    //  Throws:
0558    //       TSQLException - if a database access error occurs
0559 
0560    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0561 
0562    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0563       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0564       return "";
0565    }
0566 
0567    return imp->fColumnTypeNames[column-1];
0568 }
0569 
0570 //___________________________________________________________________
0571 Bool_t TSQLResultSetMetaData::IsReadOnly( Int_t column )                   
0572 {
0573    // Indicates whether a column Is definitely not writable.
0574    //
0575    //  Parameters:
0576    //       column - the first column is 1, the second is 2, ...
0577    //  Returns:
0578    //       kTRUE if so
0579    //  Throws:
0580    //       TSQLException - if a database access error occurs
0581 
0582    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0583 
0584    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0585       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0586       return (kTRUE);
0587    }
0588 
0589    return (!(imp->MYSQL_RES->fields[column-1].table && imp->MYSQL_RES->fields[column-1].table[0]));
0590 }
0591 
0592 //___________________________________________________________________
0593 Bool_t TSQLResultSetMetaData::IsWritable( Int_t column )                   
0594 {
0595    // Indicates whether it is possible for a write on the column 
0596    // to succeed.
0597    //
0598    //  Parameters:
0599    //       column - the first column is 1, the second is 2, ...
0600    //  Returns:
0601    //       kTRUE if so
0602    //  Throws:
0603    //       TSQLException - if a database access error occurs
0604 
0605    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0606 
0607    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0608       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0609       return kFALSE;
0610    }
0611 
0612    return (imp->MYSQL_RES->fields[column-1].table && imp->MYSQL_RES->fields[column-1].table[0]);
0613 }
0614 
0615 //___________________________________________________________________
0616 Bool_t TSQLResultSetMetaData::IsDefinitelyWritable( Int_t column )
0617 {                             
0618    // Indicates whether a write on the column will definitely succeed.
0619    //
0620    //  Parameters:
0621    //       column - the first column is 1, the second is 2, ...
0622    //  Returns:
0623    //       kTRUE if so
0624    //  Throws:
0625    //       TSQLException - if a database access error occurs
0626    //
0627    // Comment: the same as TSQLResultSetMetaData::IsWritable()
0628 
0629    MySQLResultSetPrivate* imp = (MySQLResultSetPrivate*)fImp;
0630 
0631    if( (UInt_t)(column-1) >= imp->fMYSQL_RES->field_count ) {
0632       Throw(new TSQLException(Form("Invalid column number ( %d > %d )",column,imp->fMYSQL_RES->field_count+1),"S1002",);
0633       return kFALSE;
0634    }
0635 
0636    return (imp->MYSQL_RES->fields[column-1].table && imp->MYSQL_RES->fields[column-1].table[0]);
0637 }