List:MySQL ODBC« Previous MessageNext Message »
From:Michael Widenius Date:June 6 1999 12:03pm
Subject:Re: unixODBC - MyODBC
View as plain text  
>>>>> "Peter" == Peter Harvey <pharvey@stripped> writes:

>> MySQL only supports table name sizes up to 64;  Do you really have
>> table names with more than 64 characters?

Peter> No. I was passing the buffer size and not the table name length. I
Peter> changed this to SQL_NTS and the problem is gone. Just did not expect the
Peter> error from this situation. No real problem.

>> 
Peter> 2. There still seem to be some issues with StarOffice 5.0 and
Peter> MyODBC.  One can create a StarOffice db fine but not all
Peter> functionality is availible. I guess its something for future
Peter> consideration.
>> 
>> Do you have any ideas about this?  Have you tried to get a trace file
>> of this?
>> 

Peter> No... but I plan on revisiting this during my next test session.

>> 
Peter> 3. The DataManager is picking up two SQLSpecialColumns, each
Peter> called '2'.  Apparently MyODBC does not handle
Peter> SQL_BEST_ROWID. I have to look at this closer but I would
Peter> imagine that it would be required for positional update/delete
Peter> as a first choice to determine the row id. I also think the
Peter> result set expected may differ from the result set generated in
Peter> terms of column order.
>> 
>> MyODBC should be able to handle both SQL_BEST_ROWID and SQLROWVER
>> without problems.
>> 
>> Can you get mail me an MyODBC trace file that shows this?
>> 

Peter> No... but I plan on revisiting this during my next test session. Note; a
Peter> "grep  SQL_BEST_ROWID *" on the sources shows no refs.

The source of SQLSpecialColumns follows:

------------

SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT hstmt,SQLUSMALLINT fColType,
				  SQLCHAR FAR *szTableQualifier,
				  SQLSMALLINT cbTableQualifier,
				  SQLCHAR FAR *szTableOwner,SQLSMALLINT cbTableOwner,
				  SQLCHAR FAR *szTableName,SQLSMALLINT cbTableName,
				  SQLUSMALLINT     fScope,SQLUSMALLINT fNullable)
{
  char buff[80],table_name[NAME_LEN+1];
  uint field_count;
  ulong transfer_length,precision,display_size;
  STMT FAR *stmt=(STMT FAR*) hstmt;
  char **row;
  MEM_ROOT *alloc;
  bool primary_key;
  MYSQL_FIELD *field;
  DBUG_ENTER("SQLSpecialColumns");

  if (check_parameters(hstmt,szTableQualifier,cbTableQualifier,szTableOwner,
		       cbTableOwner,szTableName,&cbTableName,table_name,1))
    DBUG_RETURN(SQL_ERROR);

  if (!(stmt->result=mysql_list_fields(&stmt->dbc->mysql,table_name,0)))
  {
    strmov(stmt->dbc->sqlstate,"S1000");
    return(SQL_ERROR);
  }

  if (fColType == SQL_ROWVER)
  {						/* Find possible timestamp */
    stmt->result_array=
      (char**) my_malloc(sizeof(char*)*SQLSPECIALCOLUMNS_FIELDS*
			 stmt->result->field_count, MYF(MY_FAE | MY_ZEROFILL));
    /* convert mysql fields to data that odbc wants */
    alloc=&stmt->result->field_alloc;
    field_count=0;
    mysql_field_seek(stmt->result,0);
    for (row= stmt->result_array ;
         (field = mysql_fetch_field(stmt->result)) ;
         )
    {
      int type;
      if ((field->type != FIELD_TYPE_TIMESTAMP))
        continue;
      field_count++;
      sprintf(buff,"%d",SQL_SCOPE_SESSION);
      row[0]=strdup_root(alloc,buff);
      row[1]= field->name;
     
type=unireg_to_sql_datatype(stmt,field,buff,&transfer_length,&precision,&display_size);
      row[3]=strdup_root(alloc,buff);
      sprintf(buff,"%d",type);
      row[2]=strdup_root(alloc,buff);
      sprintf(buff,"%d",precision);
      row[4]=strdup_root(alloc,buff);
      sprintf(buff,"%d",transfer_length);
      row[5]=strdup_root(alloc,buff);
      sprintf(buff,"%d",field->decimals);
      row[6]=strdup_root(alloc,buff);
      sprintf(buff,"%d",SQL_PC_NOT_PSEUDO);
      row[7]=strdup_root(alloc,buff);
      row+=SQLSPECIALCOLUMNS_FIELDS;
    }
    stmt->result->row_count=field_count;
    mysql_link_fields(stmt,SQLSPECIALCOLUMNS_fields,
		      SQLSPECIALCOLUMNS_FIELDS);
    DBUG_RETURN(SQL_SUCCESS);
  }

  /*
   * The optimal set of columns for identifing a row is either
   * the primary key, or if there is no primary key, then
   * all the fields.
   */

  /* Check if there is a primary (unique) key */
  primary_key=0;
  while ((field = mysql_fetch_field(stmt->result)))
  {
    if (field->flags & PRI_KEY_FLAG)
    {
      primary_key=1;
      break;
    }
  }
  stmt->result_array=
    (char**) my_malloc(sizeof(char*)*SQLSPECIALCOLUMNS_FIELDS*
		       stmt->result->field_count, MYF(MY_FAE | MY_ZEROFILL));

  /* convert mysql fields to data that odbc wants */
  alloc=&stmt->result->field_alloc;
  field_count=0;
  mysql_field_seek(stmt->result,0);
  for (row= stmt->result_array ;
       (field = mysql_fetch_field(stmt->result)) ;
       )
  {
    int type;
    if (primary_key && !(field->flags & PRI_KEY_FLAG))
      continue;
    field_count++;
    sprintf(buff,"%d",SQL_SCOPE_SESSION);
    row[0]=strdup_root(alloc,buff);
    row[1]= field->name;
   
type=unireg_to_sql_datatype(stmt,field,buff,&transfer_length,&precision,&display_size);
    row[3]=strdup_root(alloc,buff);
    sprintf(buff,"%d",type);
    row[2]=strdup_root(alloc,buff);
    sprintf(buff,"%d",precision);
    row[4]=strdup_root(alloc,buff);
    sprintf(buff,"%d",transfer_length);
    row[5]=strdup_root(alloc,buff);
    sprintf(buff,"%d",field->decimals);
    row[6]=strdup_root(alloc,buff);
    sprintf(buff,"%d",SQL_PC_NOT_PSEUDO);
    row[7]=strdup_root(alloc,buff);
    row+=SQLSPECIALCOLUMNS_FIELDS;
  }
  stmt->result->row_count=field_count;
  mysql_link_fields(stmt,SQLSPECIALCOLUMNS_fields,
		    SQLSPECIALCOLUMNS_FIELDS);
  DBUG_RETURN(SQL_SUCCESS);
}

----------

As you can see, MyODBC only checks for SQL_ROWVER and assumes the
value is SQL_BEST_ROWID in the other case.
(Thinking about the changing ODBC standard, I must probably add a test 
if the argument is something else...)

Regards,
Monty
Thread
unixODBC - MyODBCPeter Harvey5 Jun
  • unixODBC - MyODBCMichael Widenius6 Jun
  • Re: unixODBC - MyODBCPeter Harvey6 Jun
    • Re: unixODBC - MyODBCMichael Widenius6 Jun