1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Files
mariadb/sql
Aleksey Midenkov c441e4df14 MDEV-17613 Read sole now-partition for non-historical versioned query
When a versioned table stores its history in partitions, an implicit
query (no FOR SYSTEM_TIME) needs only current rows, which all live in
the current partition. vers_setup_conds() no longer adds a row_end
condition for such a table, and prune_partitions() restricts
read_partitions to the current partition instead.

read_partitions is reset to all partitions every statement in
open_table(), so the restriction must be applied on each execution.
prune_partitions() runs on each execution, also for merged derived
tables and views, where vers_setup_conds() is not called again. Both
functions guard with !vers_conditions.was_set(). In prune_partitions()
!is_set() would not do: set_all() sets type (flips is_set()) but not
orig_type (was_set()), so is_set() would be true on prepared-statement /
stored-procedure re-executions and skip the restriction, leaving history
partitions readable - rows matched then grow on each execute/call.

A query whose time comes from @@system_versioning_asof must still read
history, so the restriction is also skipped when from_sysvar is set.
init_from_sysvar() sets this new flag rather than orig_type, so
was_set(), print() and the write lock check still see only an explicit
FOR SYSTEM_TIME. Like orig_type, the flag persists to prepared-statement
re-execution.

EXPLAIN no longer shows "Using where" for such a query: correctness now
comes from partition selection rather than a row_end filter.

With sql_safe_updates, DELETE without WHERE on such a table is now
rejected even with LIMIT, as for a non-versioned table. With an index
on row_end, UPDATE or DELETE without WHERE (UPDATE also without LIMIT)
is now rejected too: it was accepted as a range scan on row_end. A
versioned table without SYSTEM_TIME partitions keeps the old behavior
(MDEV-41393).
2026-10-16 15:44:12 +03:00
..
2026-05-08 08:00:01 +02:00
2026-10-15 20:25:34 +02:00
…
2026-07-23 11:12:27 +02:00
2026-07-28 13:14:38 +02:00
…
2025-09-04 18:08:39 +03:00
2024-01-19 09:07:48 +02:00
…
…
…
2024-12-02 11:35:34 +02:00
2024-11-29 12:37:46 +02:00
2024-10-30 15:11:17 +01:00
2026-01-28 21:52:18 +01:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2024-12-02 11:35:34 +02:00
2023-12-21 02:14:59 +01:00
…
…
…
2024-01-27 12:09:54 +01:00
2024-01-27 12:09:54 +01:00
2026-10-15 20:25:34 +02:00
2026-06-15 12:50:45 +02:00
2025-09-04 18:08:39 +03:00
2026-08-30 17:39:50 +02:00
2026-10-15 20:25:34 +02:00
2024-11-29 13:43:17 +02:00
…
…
2026-10-15 20:25:34 +02:00
2026-10-13 07:49:28 +03:00
2024-12-02 11:35:34 +02:00
2024-12-05 10:11:58 +01:00
2026-08-19 08:40:05 +02:00
2026-10-15 20:25:34 +02:00
2026-08-19 08:13:54 +02:00
2026-01-28 14:22:20 +01:00
2026-10-15 20:25:34 +02:00
2026-01-28 21:52:18 +01:00
2026-01-28 14:22:20 +01:00
2026-01-28 14:22:20 +01:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2024-12-02 11:35:34 +02:00
2026-10-15 20:25:34 +02:00
2024-11-29 13:43:17 +02:00
2024-07-08 22:40:16 +02:00
2024-06-17 12:02:03 +03:00
2025-04-26 10:53:02 +02:00
2024-05-21 19:38:51 +02:00
2023-11-14 18:33:03 +01:00
2025-04-26 10:53:02 +02:00
2026-10-13 07:04:14 +03:00
2026-08-19 08:40:05 +02:00
2026-10-13 07:04:14 +03:00
2026-05-08 08:00:01 +02:00
…
…
2025-09-04 18:08:39 +03:00
2026-04-01 10:49:05 +03:00
…
2024-09-18 07:38:49 +03:00
2024-12-02 11:35:34 +02:00
2023-11-08 16:23:30 +01:00
2026-10-15 20:25:34 +02:00
2024-05-21 19:38:51 +02:00
2026-01-28 21:52:18 +01:00
2026-10-13 07:04:14 +03:00
2026-08-19 08:40:05 +02:00
2026-07-28 13:14:38 +02:00
2024-12-02 11:35:34 +02:00
2026-07-28 13:14:38 +02:00
2026-05-08 08:00:01 +02:00
2026-08-19 08:40:05 +02:00
2026-05-08 08:00:01 +02:00
2024-12-02 11:35:34 +02:00
…
2025-09-04 18:08:39 +03:00
2024-07-22 15:14:50 +02:00
2026-10-15 20:25:34 +02:00
2026-05-08 08:00:01 +02:00
2026-10-13 07:49:28 +03:00
2026-06-15 12:50:45 +02:00
2026-07-28 13:14:38 +02:00
2026-10-13 07:04:14 +03:00
2026-10-13 07:04:14 +03:00
2026-08-19 08:40:05 +02:00
2026-08-19 08:40:05 +02:00
2026-06-15 12:50:45 +02:00
2026-06-15 10:43:23 +02:00
2024-12-02 11:35:34 +02:00
2026-08-19 08:40:05 +02:00
2026-08-19 08:40:05 +02:00
2026-10-13 07:04:14 +03:00
2025-10-28 17:49:51 +01:00
2025-10-28 17:49:51 +01:00
2026-10-13 07:04:14 +03:00
2026-10-13 07:04:14 +03:00
2026-10-13 07:04:14 +03:00
2024-12-02 11:35:34 +02:00
2026-08-19 08:13:54 +02:00
2025-09-04 18:08:39 +03:00
2026-10-15 20:25:34 +02:00
2025-01-14 23:45:41 +01:00
2024-06-24 13:09:47 +03:00
2025-01-30 12:01:11 +01:00
2024-11-29 13:43:17 +02:00
2026-05-08 08:00:01 +02:00
2025-09-04 18:08:39 +03:00
2024-01-18 19:22:23 +02:00
2026-04-01 10:49:05 +03:00
2024-12-02 11:35:34 +02:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2026-01-28 21:52:18 +01:00
2026-01-02 11:06:05 +02:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2026-07-23 11:12:27 +02:00
2026-07-23 11:12:27 +02:00
2026-10-15 20:25:34 +02:00
2025-03-03 11:07:56 +02:00
2026-03-17 18:57:42 +01:00
2026-01-28 21:52:18 +01:00
2026-08-19 08:40:05 +02:00
…
2024-08-21 09:30:54 +02:00
2026-04-01 10:49:05 +03:00
2025-09-24 13:40:09 +03:00
2025-09-04 18:08:39 +03:00
2024-06-27 10:26:09 +03:00
2026-10-15 20:25:34 +02:00
2024-10-30 15:11:17 +01:00
2024-11-29 12:37:46 +02:00
…
2026-10-13 07:04:14 +03:00
2025-09-19 12:31:14 +03:00
2025-09-04 18:08:39 +03:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2026-05-08 08:00:01 +02:00
2024-04-15 18:54:30 +02:00
2026-10-15 20:25:34 +02:00
2026-01-28 21:52:18 +01:00
2024-07-03 12:45:30 +02:00
2026-10-15 20:25:34 +02:00
2023-12-17 11:20:43 +01:00
2026-08-19 08:40:05 +02:00
2026-07-23 11:12:27 +02:00
2026-08-19 08:40:05 +02:00
2023-12-02 01:02:50 +01:00
2026-10-13 07:04:14 +03:00
2025-09-04 18:08:39 +03:00
2026-05-08 08:00:01 +02:00
2026-08-19 08:40:05 +02:00
2026-03-17 11:30:41 +02:00
2024-03-28 10:51:36 +02:00
2025-09-16 17:01:39 +03:00
2026-10-15 20:25:34 +02:00
2026-07-28 13:14:38 +02:00
2025-01-30 12:01:11 +01:00
2025-03-27 08:01:47 +02:00
2023-09-25 13:06:57 +10:00
2024-01-18 19:22:23 +02:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2024-12-02 11:35:34 +02:00
2024-11-23 08:14:23 -07:00
2026-08-19 08:40:05 +02:00
2026-07-28 13:14:38 +02:00
2026-07-28 13:14:38 +02:00
2026-06-15 12:50:45 +02:00
2026-10-15 20:25:34 +02:00
2026-10-15 20:25:34 +02:00
2026-08-19 08:40:05 +02:00
2026-08-19 08:40:05 +02:00
2026-10-15 20:25:34 +02:00
2025-09-04 18:08:39 +03:00
2024-06-24 13:09:47 +03:00
2025-07-28 19:40:10 +02:00
…
2024-02-15 13:53:21 +01:00
2024-12-02 11:35:34 +02:00
2024-12-02 11:35:34 +02:00
2026-08-19 08:40:05 +02:00
2026-10-15 20:25:34 +02:00
2025-11-28 12:56:27 +02:00
2025-11-28 12:56:27 +02:00
2024-01-02 17:37:58 +02:00
2024-06-27 10:26:09 +03:00
2026-10-13 07:04:14 +03:00
2026-06-21 15:32:20 +02:00
2026-08-19 08:40:05 +02:00
2024-10-03 13:24:43 +03:00
2024-09-09 13:50:38 +03:00
2026-10-15 20:25:34 +02:00
2026-07-23 11:12:27 +02:00
2026-07-23 11:12:27 +02:00
2026-08-19 08:40:05 +02:00
2026-04-01 10:49:05 +03:00
2025-07-28 19:40:10 +02:00