pg_surgery
模組提供各種函數來對損壞的關係執行手術。 這些函數在設計上是不安全的,使用它們可能會損壞(或進一步損壞)您的資料庫。 例如,這些函數可以很容易地用來使表格與其自身的索引不一致,導致 UNIQUE
或 FOREIGN KEY
限制違規,甚至使 Tuple 可見,當讀取這些 Tuple 時,會導致資料庫伺服器崩潰。 應該非常謹慎地使用它們,並且只能作為最後的手段。
heap_force_kill(regclass, tid[]) returns void
heap_force_kill
將 「已使用」 行指標標記為 「已死亡」,而不檢查 Tuple。 此函數的預期用途是強制移除無法以其他方式存取的 Tuple。 例如
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
將 Tuple 標記為已凍結,而不檢查 Tuple 資料。 此函數的預期用途是使可存取的 Tuple 由於損壞的可見性資訊而無法存取,或者由於損壞的可見性資訊而阻止成功清理表格。 例如
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>
如果您在文件中發現任何不正確、與您使用特定功能的經驗不符或需要進一步澄清的地方,請使用此表單來報告文件問題。