@@ -125,6 +125,10 @@ update_query(int qhash, int fhash,
125125ScanKeyData key ;
126126SnapshotData snap ;
127127
128+ /* Couldn't allow to write if xact must be read-only. */
129+ if (XactReadOnly )
130+ return false;
131+
128132reloid = RelnameGetRelid ("aqo_queries_query_hash_idx" );
129133if (!OidIsValid (reloid ))
130134{
@@ -225,6 +229,10 @@ add_query_text(int qhash)
225229Oid reloid ;
226230char * text_str ;
227231
232+ /* Couldn't allow to write if xact must be read-only. */
233+ if (XactReadOnly )
234+ return false;
235+
228236reloid = RelnameGetRelid ("aqo_query_texts_query_hash_idx" );
229237if (!OidIsValid (reloid ))
230238{
@@ -386,6 +394,10 @@ update_fss(int fhash, int fsshash, int nrows, int ncols,
386394ScanKeyData key [2 ];
387395bool result = true;
388396
397+ /* Couldn't allow to write if xact must be read-only. */
398+ if (XactReadOnly )
399+ return false;
400+
389401reloid = RelnameGetRelid ("aqo_fss_access_idx" );
390402if (!OidIsValid (reloid ))
391403{
@@ -575,6 +587,10 @@ update_aqo_stat(int qhash, QueryStat *stat)
575587IndexScanDesc scan ;
576588ScanKeyData key ;
577589
590+ /* Couldn't allow to write if xact must be read-only. */
591+ if (XactReadOnly )
592+ return ;
593+
578594reloid = RelnameGetRelid ("aqo_query_stat_idx" );
579595if (!OidIsValid (reloid ))
580596{