Giter VIP home page Giter VIP logo

Comments (3)

RingsC avatar RingsC commented on June 5, 2024

bool Query_block::optimize(THD *thd) {
DBUG_TRACE;

assert(join == nullptr);
JOIN const join_local = new (thd->mem_root) JOIN(thd, this);
if (!join_local) return true; /
purecov: inspected */

/*
Updating Query_block::join requires acquiring THD::LOCK_query_plan
to avoid races when EXPLAIN FOR CONNECTION is used.
*/
thd->lock_query_plan();
join = join_local;
thd->unlock_query_plan();

if (join->optimize()) return true;

if (join->zero_result_cause && !is_implicitly_grouped()) return false;

for (Query_expression *query_expression = first_inner_query_expression();
query_expression;
query_expression = query_expression->next_query_expression()) {
// Derived tables and const subqueries are already optimized
if (!query_expression->is_optimized() &&
query_expression->optimize(thd, /materialize_destination=/nullptr,
/create_iterators=/false))
return true;
}

return false;
}

from mysql-server-mysql-8.0.30.

RingsC avatar RingsC commented on June 5, 2024

the definition of query_expression:

/**
This class represents a query expression (one query block or
several query blocks combined with UNION).

/
class Query_expression {
/
*
Intrusive double-linked list of all query expressions
immediately contained within the same query block.
*/
Query_expression *next;
Query_expression **prev;

Query_block:
/**
This class represents a query block, aka a query specification, which is
a query consisting of a SELECT keyword, followed by a table list,
optionally followed by a WHERE clause, a GROUP BY, etc.

/
class Query_block {
public:
/
*
@note the group_by and order_by lists below will probably be added to the
constructor when the parser is converted into a true bottom-up design.

      //SQL_I_LIST<ORDER> *group_by, SQL_I_LIST<ORDER> order_by

*/
Query_block(MEM_ROOT *mem_root, Item *where, Item *having);

from mysql-server-mysql-8.0.30.

RingsC avatar RingsC commented on June 5, 2024

it's similar to st_select_lex_unit and st_select_lex.

the definition:
/**
This class represents a query block, aka a query specification, which is
a query consisting of a SELECT keyword, followed by a table list,
optionally followed by a WHERE clause, a GROUP BY, etc.

*/
class st_select_lex: public Sql_alloc

/**
This class represents a query expression (one query block or
several query blocks combined with UNION).

*/
class st_select_lex_unit: public Sql_alloc
{

the Query_expression = st_select_lex_unit, and Query_block = st_select_lex.

from mysql-server-mysql-8.0.30.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.