[HyperDB] dbDeltas with HyperDB

Chris Morrell chris at cmorrell.com
Wed Oct 19 20:26:43 UTC 2011


Really good point.  dbDelta could drop the SHOW TABLES and the loop through
those tables and perform exactly the same…

  <http://cmorrell.com/> *Chris Morrell*  Web: http://cmorrell.com  Twitter:
@inxilpro <http://twitter.com/inxilpro>



On Wed, Oct 19, 2011 at 1:43 PM, Andy Skelton <skeltoac at gmail.com> wrote:

> Why does dbDelta bother with SHOW TABLES at all? Why not just loop
> over the table names and do DESCRIBE TABLE on each one?
>
> foreach ( $cqueries as $table => $qry ) {
>    $tablefields = $wpdb->get_results( "DESCRIBE $table" );
>    if ( $tablefields ) {
>        // Generate ALTER TABLE statements
>    } else {
>        // Use CREATE TABLE statement
>    }
> }
>
> Andy
>
> On Wed, Oct 19, 2011 at 12:23 PM, Chris Morrell <chris at cmorrell.com>
> wrote:
> > Hey everyone,
> >
> > I'm having an issue with HyperDB and the dbDelta function.  dbDelta runs
> the
> > following code:
> >
> > $tables = $wpdb->get_col('SHOW TABLES;')
> >
> > And then loops through the results.  Well, this can be a real issue with
> > sharding, where each table can be located on a different database server.
> >  It seems to me that the only way to solve this problem would be to patch
> > Wordpress core (have dbDelta check each table's existence individually)
> and
> > also patch HyperDB to properly parse the table name from the individual
> SHOW
> > TABLES query.  There's an existing core
> > ticket<http://core.trac.wordpress.org/ticket/17998>that begins to
> > address a similar issue, but it won't work with HyperDB.
> >
> > Right now I'm just trying to figure out how to approach the issue.  It
> seems
> > like it would affect just about any plugin that uses dbDelta to upgrade
> > their database tables.  Has anyone else run into this problem?  Any good
> > solutions?
> >
> > Thanks!
> >  <http://cmorrell.com/> *Chris Morrell*  Web: http://cmorrell.com Twitter:
> > @inxilpro <http://twitter.com/inxilpro>
> > _______________________________________________
> > HyperDB mailing list
> > HyperDB at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/hyperdb
> >
> _______________________________________________
> HyperDB mailing list
> HyperDB at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/hyperdb
>


More information about the HyperDB mailing list