List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:October 8 1999 1:55am
Subject:Re: finding AUTO_INCREMENT type from client side
View as plain text  
>>>>> "Jim" == Jim O'Quinn <oquinn@stripped> writes:

>> > Is there any way to programmatically figure out
>> > if a field is AUTO_INCREMENT?  I can do something
>> > like:
>> >
>> >   for ($x=0; $x < $sth->numfields; $x++) {
>> >     $colname  = $sth->name->[$x];
>> >     $size     = $sth->length->[$x];
>> >     $maxlen   = $sth->length->[$x];
>> >     $type     = $sth->type->[$x];
>> >   }
>> >
>> > But from what I can tell, 'type' is a INT and
>> > there is no way to tell if it is AUTO_INCREMENT
>> > or not?
>> >
>> > Does anyone know of a way to figure out if a
>> > field is AUTO_INCREMENT?
>> >
>> 
>> Take a look at mysqlshow.c


Jim> I did, and it looks like I have to re-query
Jim> the database to figure out if the field
Jim> is AUTO_INCREMENT or not ('show fields from 
Jim> SOME_TABLE_NAME') and then parse the resulting
Jim> data, but I was hoping to get the info back 
Jim> somewhere in the meta-data from the original
Jim> query and not have to re-query.  

Jim> Any thoughts?

Hi!

In C, you can check if a column is an auto_increment field by doing:

MYSQL_FIELD *field
....

if (field->flags & AUTO_INCREMENT_FLAG)
{
...
}

Regards,
Monty
Thread
finding AUTO_INCREMENT type from client sideJim O'Quinn7 Oct
  • Re: finding AUTO_INCREMENT type from client sideThimble Smith7 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn7 Oct
    • Re: finding AUTO_INCREMENT type from client sideMichael Widenius8 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn8 Oct
    • Re: finding AUTO_INCREMENT type from client sideThimble Smith8 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn8 Oct
    • Re: finding AUTO_INCREMENT type from client sideThimble Smith8 Oct
    • Re: finding AUTO_INCREMENT type from client sideMichael Widenius10 Oct