8000 Disallow AQO to write into the ML-tables if can be detected that · postgrespro/aqo@91bed68 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91bed68

Browse files
committed
Disallow AQO to write into the ML-tables if can be detected that
the query must be read-only (by the flag XactReadOnly).
1 parent b46f0bb commit 91bed68

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

storage.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ update_query(int qhash, int fhash,
125125
ScanKeyData key;
126126
SnapshotData snap;
127127

128+
/* Couldn't allow to write if xact must be read-only. */
129+
if (XactReadOnly)
130+
return false;
131+
128132
reloid = RelnameGetRelid("aqo_queries_query_hash_idx");
129133
if (!OidIsValid(reloid))
130134
{
@@ -228,6 +232,10 @@ add_query_text(int qhash)
228232
values[0] = Int32GetDatum(qhash);
229233
values[1] = CStringGetTextDatum(query_text);
230234

235+
/* Couldn't allow to write if xact must be read-only. */
236+
if (XactReadOnly)
237+
return false;
238+
231239
reloid = RelnameGetRelid("aqo_query_texts_query_hash_idx");
232240
if (!OidIsValid(reloid))
233241
{
@@ -374,6 +382,10 @@ update_fss(int fhash, int fsshash, int nrows, int ncols,
374382
ScanKeyData key[2];
375383
bool result = true;
376384

385+
/* Couldn't allow to write if xact must be read-only. */
386+
if (XactReadOnly)
387+
return false;
388+
377389
reloid = RelnameGetRelid("aqo_fss_access_idx");
378390
if (!OidIsValid(reloid))
379391
{
@@ -563,6 +575,10 @@ update_aqo_stat(int qhash, QueryStat *stat)
563575
IndexScanDesc scan;
564576
ScanKeyData key;
565577

578+
/* Couldn't allow to write if xact must be read-only. */
579+
if (XactReadOnly)
580+
return;
581+
566582
reloid = RelnameGetRelid("aqo_query_stat_idx");
567583
if (!OidIsValid(reloid))
568584
{

0 commit comments

Comments
 (0)
0