Make WordPress Core

Opened 3 months ago

Closed 2 months ago

#63777 closed enhancement (fixed)

wpdb::get_table_from_query() doesn't support queries with `SET STATEMENT ... FOR`

Reported by: dd32's profile dd32 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: low
Severity: minor Version:
Component: Database Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

MariaDB supports setting various parameters for queries, but wpdb::get_table_from_query() doesn't currently understand this.

https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/set-commands/set-statement

For example:

wp> var_dump( $wpdb->get_table_from_query( "SET STATEMENT max_statement_time=10 FOR SELECT something FROM table_name WHERE something-is-expensive" ) );
bool(false)

I'm not sure how useful supporting this would be to most WordPress plugins, nor how it would apply to other database engines.

Change History (3)

This ticket was mentioned in PR #9374 on WordPress/wordpress-develop by @dd32.


3 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @SergeyBiryukov
2 months ago

  • Milestone changed from Awaiting Review to 6.9

#3 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 60622:

Database: Add support for SET STATEMENT in wpdb::get_table_from_query().

MariaDB supports setting various parameters for queries. This commit ensures that wpdb can properly retrieve the table name from such queries.

Reference: MariaDB Documentation: SET STATEMENT.

Follow-up to [30345].

Props dd32.
Fixes #63777.

Note: See TracTickets for help on using tickets.