Skip to content

MDEV-39347: Referred databases are not present in the context#4951

Merged
bsrikanth-mariadb merged 1 commit intobb-12.3-MDEV-38805-dev-sprint-work-2from
12.3-MDEV-39347-referred-db-create-stmt-not-written-to-ctx
Apr 24, 2026
Merged

MDEV-39347: Referred databases are not present in the context#4951
bsrikanth-mariadb merged 1 commit intobb-12.3-MDEV-38805-dev-sprint-work-2from
12.3-MDEV-39347-referred-db-create-stmt-not-written-to-ctx

Conversation

@bsrikanth-mariadb
Copy link
Copy Markdown
Contributor

Currently, only create/use DDLs for the database that is in the current thread is stored in the context.
However, we do store CREATE DDL statements of other database tables in the context, if they are referred by the query. So, while replaying the context, if the other database is not present in the system, then we get an error.

== SOLUTION ==
Store CREATE DATABASE DDLs of the databases to the context, if any of those database tables are referred by the original query.

@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 12.3-MDEV-39347-referred-db-create-stmt-not-written-to-ctx branch from 3529117 to 2366ead Compare April 23, 2026 00:29
Comment thread sql/opt_context_store_replay.cc Outdated
1 OOM error
*/
static bool store_db_ddl(THD *thd, HASH *db_name_hash, String &sql_script,
const char *db_name, bool req_use_db_stmt= false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool req_use_db_stmt= false ... There are only two uses of the function. Please make the parameter non- optional.

Copy link
Copy Markdown
Member

@spetrunia spetrunia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to push after the above is addressed.

Currently, only create/use DDLs for the database that is in the
current thread is stored in the context.
However, we do store CREATE DDL statements of other database tables
in the context, if they are referred by the query.
So, while replaying the context, if the other database is not present
in the system, then we get an error.

== SOLUTION ==
Store CREATE DATABASE DDLs of the databases to the context, if any of those database tables are referred by the original query.
@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 12.3-MDEV-39347-referred-db-create-stmt-not-written-to-ctx branch from 2366ead to 8cc3cfb Compare April 24, 2026 08:33
@bsrikanth-mariadb bsrikanth-mariadb merged commit 8cc3cfb into bb-12.3-MDEV-38805-dev-sprint-work-2 Apr 24, 2026
12 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants