List:Internals« Previous MessageNext Message »
From:Jay Pipes Date:June 25 2009 12:38pm
Subject:Re: MySql coding style: Request for deprecation of UPPERCASE typedefs
View as plain text  
Tor Didriksen wrote:
> On Wed, 24 Jun 2009 17:14:03 +0200, Michael Widenius 
> <monty@stripped> wrote:
>> There is no 'of course' in that.
>>
>> If you try to do every include file self-contained, you need a LOT of
>> more includes 'just in case' and dependents that just creates more
>> code, more parsing without giving you anything.
>>
>> MySQL was design with the idea that you in most cases only have to
>> include one (but in practice a few) include files in each source file.
> 
> #include mysql_priv which pulls in just about everything, yes.
> This practice makes it impossible to do unit testing.
> 
> 'include or declare what you use' is a very simple rule,
> and makes the code much more maintainable and testable.

This is one of the first things we tackled in Drizzle.  We found that 
there was a spiderweb of #includes that made it:

* Nearly impossible to easily state which files were being included in 
the current source compilation, and more importantly *which order* files 
were being included (#ifdef MYSQL_SERVER anyone?!)
* Difficult to determine *where* key structures and classes were defined 
(sql_class.h, sql_base.h, structs.h, definitions.h, unireg.h, 
mysql_priv.h, etc etc etc...)
* SLOWER compilation speeds since large numbers of class and struct 
definitions needed to be "pulled in" to a source compilation for no 
reason whatsoever -- Drizzle's compilation speed has dramatically 
improved since we tackled the #include mess.

One thing I *still* haven't been able to "unplug" is the mess in 
sql_lex.h which partially compiles the parser with this wonderful block 
of ugly:

/*
   The following hack is needed because mysql_yacc.cc does not define
   YYSTYPE before including this file
*/

#ifdef DRIZZLE_SERVER
# include <drizzled/set_var.h>
# include <drizzled/item/func.h>
# ifdef DRIZZLE_YACC
#  define LEX_YYSTYPE void *
# else
#  if defined(DRIZZLE_LEX)
#   include <drizzled/lex_symbol.h>
#   include <drizzled/sql_yacc.h>
#   define LEX_YYSTYPE YYSTYPE *
#  else
#   define LEX_YYSTYPE void *
#  endif /* defined(DRIZZLE_LEX) */
# endif /* DRIZZLE_YACC */
#endif /* DRIZZLE_SERVER */

I believe this is the very last place that DRIZZLE_SERVER (MYSQL_SERVER) 
is used in the Drizzle source code.  Every time I've tried to break this 
monster up, I've gone down a rathole...but I know it's possible to do 
it.  Maybe Mats will figure it out and I can buy him a beer or two :)

Cheers,

Jay
Thread
MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen22 Jun
  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl22 Jun
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius24 Jun
      • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen25 Jun
        • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
      • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl25 Jun
        • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
          • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsJay Pipes27 Jun
          • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen29 Jun
          • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl29 Jun
            • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKristian Nielsen29 Jun
              • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen30 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl30 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKristian Nielsen30 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen1 Jul
                    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKristian Nielsen1 Jul
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKonstantin Osipov1 Jul
              • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKonstantin Osipov1 Jul
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKristian Nielsen2 Jul
  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKonstantin Osipov22 Jun
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsRoy Lyseng22 Jun
      • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen23 Jun
        • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl23 Jun
          • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen23 Jun
            • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl23 Jun
              • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl30 Jun
            • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius24 Jun
              • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen25 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsJonas Oreland25 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsDavi Arnaut25 Jun
                    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsJay Pipes25 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl25 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl30 Jun
              • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMats Kindahl25 Jun
                • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius27 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsJay Pipes27 Jun
                    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius30 Jun
                  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsJay Pipes27 Jun
                    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsMichael Widenius1 Jul
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen23 Jun
  • Re: MySql coding style: Request for deprecation of UPPERCASEtypedefsSergei Golubchik22 Jun
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen23 Jun
      • Re: MySql coding style: Request for deprecation of UPPERCASEtypedefsSergei Golubchik23 Jun
        • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen23 Jun
  • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsAlex Esterkin1 Jul
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsTor Didriksen1 Jul
    • Re: MySql coding style: Request for deprecation of UPPERCASE typedefsKonstantin Osipov1 Jul