List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:October 10 1999 4:38pm
Subject:Re: finding AUTO_INCREMENT type from client side
View as plain text  
Hi!

>>>>> "Jim" == Jim O'Quinn <oquinn@stripped> writes:

>> > T_SOME_TABLE.ID               - auto_increment
>> > T_SOME_TALBE.SOME_CHAR                - char
>> >
>> > my $obj       = new T_SOME_TABLE();
>> > $obj->setSomeChar(12);
>> > $obj->store;  # does update/insert
>> >
>> >Then I can do:
>> >
>> > print $obj->getSomeChar;      # a '12' shows up
>> > print $obj->getId;            # here is where I need to get
>> >                                # the value that was auto_incremented
>> 
<cut>

Jim> In any case, all this junk runs under Apache
Jim> mod_perl and I'm thinking about caching all
Jim> the database meta-data in the web server on
Jim> web server startup where I can pull it from 
Jim> a variable and not have  to run an extra SQL 
Jim> statement and parse the results to determine 
Jim> if I've got a AUTO_INC or not, plus pulling 
Jim> it from a variable is faster than makeing 
Jim> db calls to get the  meta-data.  All of this 
Jim> came about b/c of performance tweaking anyway.

<cut>

One option is of course to patch the msql-mysql-modules so that you
can test if a column is AUTO_INCREMENT:

To fix this, you can grep after IS_BLOB in the source and add a very
similar handling of IS_AUTO:


Add near:

              case AV_ATTRIB_IS_BLOB:
                sv = boolSV(IS_BLOB(curField->flags));
                break;

something like:

              case AV_ATTRIB_IS_AUTO:
                sv = boolSV(curField->flags & AUTO_INCREMENT_FLAG ? 1: 0);
                break;

A quick search with "grep -i is_blob */*.c" should help you find the
other things to patch...


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