Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8c0c868

Browse files
vacuumdb: Fix --missing-stats-only with virtual generated columns.
Statistics aren't created for virtual generated columns, so"vacuumdb --missing-stats-only" always chooses to analyze tablesthat have them. To fix, modify vacuumdb's query for retrievingrelations that are missing statistics to exclude those columns.Oversight in commitedba754.Author: Yugo Nagata <nagata@sraoss.co.jp>Reviewed-by: Fujii Masao <masao.fujii@gmail.com>Reviewed-by: Corey Huinker <corey.huinker@gmail.com>Discussion:https://postgr.es/m/20250820104226.8ba51e43164cd590b863ce41%40sraoss.co.jpBackpatch-through: 18
1 parent5a26a3e commit8c0c868

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎src/bin/scripts/t/100_vacuumdb.pl‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@
237237
qr/cannot vacuum all databases and a specific one at the same time/,
238238
'cannot use option --all and a dbname as argument at the same time');
239239

240-
$node->safe_psql('postgres',
241-
'CREATE TABLE regression_vacuumdb_test AS select generate_series(1, 10) a, generate_series(2, 11) b;'
242-
);
240+
$node->safe_psql('postgres',q|
241+
CREATE TABLE regression_vacuumdb_test AS select generate_series(1, 10) a, generate_series(2, 11) b;
242+
ALTER TABLE regression_vacuumdb_test ADD COLUMN c INT GENERATED ALWAYS AS (a + b);
243+
|);
243244
$node->issues_sql_like(
244245
[
245246
'vacuumdb','--analyze-only',

‎src/bin/scripts/vacuumdb.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include<limits.h>
1616

17+
#include"catalog/pg_attribute_d.h"
1718
#include"catalog/pg_class_d.h"
1819
#include"common.h"
1920
#include"common/connect.h"
@@ -957,6 +958,8 @@ retrieve_objects(PGconn *conn, vacuumingOptions *vacopts,
957958
" AND a.attnum OPERATOR(pg_catalog.>) 0::pg_catalog.int2\n"
958959
" AND NOT a.attisdropped\n"
959960
" AND a.attstattarget IS DISTINCT FROM 0::pg_catalog.int2\n"
961+
" AND a.attgenerated OPERATOR(pg_catalog.<>) "
962+
CppAsString2(ATTRIBUTE_GENERATED_VIRTUAL)"\n"
960963
" AND NOT EXISTS (SELECT NULL FROM pg_catalog.pg_statistic s\n"
961964
" WHERE s.starelid OPERATOR(pg_catalog.=) a.attrelid\n"
962965
" AND s.staattnum OPERATOR(pg_catalog.=) a.attnum\n"
@@ -994,6 +997,8 @@ retrieve_objects(PGconn *conn, vacuumingOptions *vacopts,
994997
" AND a.attnum OPERATOR(pg_catalog.>) 0::pg_catalog.int2\n"
995998
" AND NOT a.attisdropped\n"
996999
" AND a.attstattarget IS DISTINCT FROM 0::pg_catalog.int2\n"
1000+
" AND a.attgenerated OPERATOR(pg_catalog.<>) "
1001+
CppAsString2(ATTRIBUTE_GENERATED_VIRTUAL)"\n"
9971002
" AND c.relhassubclass\n"
9981003
" AND NOT p.inherited\n"
9991004
" AND EXISTS (SELECT NULL FROM pg_catalog.pg_inherits h\n"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp