On 21.09.10 17.55, Tor Didriksen wrote:
> How about this instead, avoids casting and sizeof() stuff:
Good idea, done.
Roy
>
> -- didrik
>
>
> === modified file 'sql/sql_select.cc'
> --- sql/sql_select.cc 2010-09-20 14:06:02 +0000
> +++ sql/sql_select.cc 2010-09-21 15:49:41 +0000
> @@ -4490,6 +4490,12 @@
> if (!stat || !stat_ref || !table_vector)
> DBUG_RETURN(1); // Eom /* purecov: inspected */
>
> + if (!(join->positions= new (join->thd->mem_root)
> POSITION[table_count+1]))
> + DBUG_RETURN(TRUE);
> +
> + if (!(join->best_positions= new (join->thd->mem_root)
> POSITION[table_count+1]))
> + DBUG_RETURN(TRUE);
> +
> join->best_ref=stat_vector;
>
> stat_end=stat+table_count;
>
> === modified file 'sql/sql_select.h'
> --- sql/sql_select.h 2010-09-06 17:56:05 +0000
> +++ sql/sql_select.h 2010-09-21 15:47:03 +0000
> @@ -1369,7 +1369,7 @@
> advance_sj_state() for details.
> */
>
> -typedef struct st_position
> +typedef struct st_position : public Sql_alloc
> {
> /*
> The "fanout" - number of output rows that will be produced (after
> @@ -1613,7 +1613,7 @@
> */
> ha_rows fetch_limit;
> /* Finally picked QEP. This is result of join optimization */
> - POSITION best_positions[MAX_TABLES+1];
> + POSITION *best_positions;
>
> /******* Join optimization state members start *******/
> /*
> @@ -1623,7 +1623,7 @@
> TABLE_LIST *emb_sjm_nest;
>
> /* Current join optimization state */
> - POSITION positions[MAX_TABLES+1];
> + POSITION *positions;
>
> /*
> Bitmap of nested joins embedding the position at the end of the current
>
>
>
> 2010/9/21 Roy Lyseng <roy.lyseng@stripped
> <mailto:roy.lyseng@stripped>>
>
> #At file:///home/rl136806/mysql/repo/mysql-review/ based on
> revid:roy.lyseng@stripped
>
> 3245 Roy Lyseng 2010-09-21
> Refactoring: Make members positions and best_positions of class JOIN
> dynamically allocated instead of fixed-size arrays.
> This saves approx. 20 kbyte memory during optimization and execution
> for normal-sized join operations.
>
> sql/sql_select.cc
> Allocate positions and best_positions dynamically.
>
> sql/sql_select.h
> positions and best_positions (members of class JOIN) defined as
> pointers instead of arrays.
>
> modified:
> sql/sql_select.cc
> sql/sql_select.h
> === modified file 'sql/sql_select.cc'
> --- a/sql/sql_select.cc 2010-09-20 14:06:02 +0000
> +++ b/sql/sql_select.cc 2010-09-21 11:36:51 +0000
> @@ -4490,6 +4490,14 @@ make_join_statistics(JOIN *join, TABLE_L
> if (!stat || !stat_ref || !table_vector)
> DBUG_RETURN(1); // Eom /* purecov: inspected */
>
> + if (!(join->positions=
> + (POSITION *)join->thd->alloc(sizeof(POSITION)*(table_count+1))))
> + DBUG_RETURN(TRUE);
> +
> + if (!(join->best_positions=
> + (POSITION *)join->thd->alloc(sizeof(POSITION)*(table_count+1))))
> + DBUG_RETURN(TRUE);
> +
> join->best_ref=stat_vector;
>
> stat_end=stat+table_count;
>
> === modified file 'sql/sql_select.h'
> --- a/sql/sql_select.h 2010-09-06 17:56:05 +0000
> +++ b/sql/sql_select.h 2010-09-21 11:36:51 +0000
> @@ -1613,7 +1613,7 @@ public:
> */
> ha_rows fetch_limit;
> /* Finally picked QEP. This is result of join optimization */
> - POSITION best_positions[MAX_TABLES+1];
> + POSITION *best_positions;
>
> /******* Join optimization state members start *******/
> /*
> @@ -1623,7 +1623,7 @@ public:
> TABLE_LIST *emb_sjm_nest;
>
> /* Current join optimization state */
> - POSITION positions[MAX_TABLES+1];
> + POSITION *positions;
>
> /*
> Bitmap of nested joins embedding the position at the end of the current
>
>
>
> --
> MySQL Code Commits Mailing List
> For list archives: http://lists.mysql.com/commits
> To unsubscribe: http://lists.mysql.com/commits?unsub=1
>
>