pg_surgery
模組提供各種函數來對損壞的關係執行手術。 這些函數在設計上是不安全的,使用它們可能會損壞(或進一步損壞)您的資料庫。 例如,這些函數很容易被用來使表格與其自身的索引不一致,導致 UNIQUE
或 FOREIGN KEY
約束違規,甚至使 tuples 可見,當讀取它們時,會導致資料庫伺服器崩潰。 應該非常謹慎地使用它們,並且只能作為最後的手段。
heap_force_kill(regclass, tid[]) returns void
heap_force_kill
將「已使用」的行指標標記為「已失效」,而不檢查 tuples。 此函數的預期用途是強制移除無法以其他方式存取的 tuples。 例如
test=> select * from t1 where ctid = '(0, 1)'; ERROR: could not access status of transaction 4007513275 DETAIL: Could not open file "pg_xact/0EED": No such file or directory. test=# select heap_force_kill('t1'::regclass, ARRAY['(0, 1)']::tid[]); heap_force_kill ----------------- (1 row) test=# select * from t1 where ctid = '(0, 1)'; (0 rows)
heap_force_freeze(regclass, tid[]) returns void
heap_force_freeze
將 tuples 標記為已凍結,而不檢查 tuple 資料。 此函數的預期用途是使由於損壞的可見性資訊而無法存取的 tuples,或阻止表格由於損壞的可見性資訊而成功 vacuum 的 tuples,變為可存取。 例如
test=> vacuum t1; ERROR: found xmin 507 from before relfrozenxid 515 CONTEXT: while scanning block 0 of relation "public.t1" test=# select ctid from t1 where xmin = 507; ctid ------- (0,3) (1 row) test=# select heap_force_freeze('t1'::regclass, ARRAY['(0, 3)']::tid[]); heap_force_freeze ------------------- (1 row) test=# select ctid from t1 where xmin = 2; ctid ------- (0,3) (1 row)
Ashutosh Sharma <ashu.coek88@gmail.com>
如果您在文件中發現任何不正確、與特定功能的使用經驗不符或需要進一步澄清的地方,請使用此表單來報告文件問題。