static ProcessUtility_hook_type oldProcessUtilityHook = NULL;
#endif
+#if PG_VERSION_NUM >= 120000
+#define VACOPT_NOWAIT VACOPT_SKIP_LOCKED
+#endif
+
typedef enum CmdKind
{
CK_SELECT = CMD_SELECT,
VacuumParams vacstmt;
#endif
TimestampTz startStamp, endStamp;
+ int flags;
memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
vacstmt.log_min_duration = -1;
#endif
+
if (online_analyze_verbose)
startStamp = GetCurrentTimestamp();
+ flags = VACOPT_ANALYZE | VACOPT_NOWAIT |
+ ((online_analyze_verbose) ? VACOPT_VERBOSE : 0);
+
+#if PG_VERSION_NUM >= 120000
+ vacstmt.options = flags;
+#endif
analyze_rel(relOid,
#if PG_VERSION_NUM < 90500
&vacstmt
#endif
#else
makeRangeVarFromOid(relOid),
- VACOPT_ANALYZE | VACOPT_NOWAIT | ((online_analyze_verbose) ? VACOPT_VERBOSE : 0),
+#if PG_VERSION_NUM < 120000
+ flags,
+#endif
&vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
#endif
);
toremove = NIL;
}
+#if PG_VERSION_NUM >= 120000
+static int
+parse_vacuum_opt(VacuumStmt *vacstmt)
+{
+ int options = vacstmt->is_vacuumcmd ? VACOPT_VACUUM : VACOPT_ANALYZE;
+ ListCell *lc;
+
+ foreach(lc, vacstmt->options)
+ {
+ DefElem *opt = (DefElem *) lfirst(lc);
+
+ /* Parse common options for VACUUM and ANALYZE */
+ if (strcmp(opt->defname, "verbose") == 0)
+ options |= VACOPT_VERBOSE;
+ else if (strcmp(opt->defname, "skip_locked") == 0)
+ options |= VACOPT_SKIP_LOCKED;
+ else if (strcmp(opt->defname, "analyze") == 0)
+ options |= VACOPT_ANALYZE;
+ else if (strcmp(opt->defname, "freeze") == 0)
+ options |= VACOPT_FREEZE;
+ else if (strcmp(opt->defname, "full") == 0)
+ options |= VACOPT_FULL;
+ else if (strcmp(opt->defname, "disable_page_skipping") == 0)
+ options |= VACOPT_DISABLE_PAGE_SKIPPING;
+ }
+
+ return options;
+}
+#endif
+
#if PG_VERSION_NUM >= 90200
static void
else if (IsA(parsetree, VacuumStmt))
{
VacuumStmt *vac = (VacuumStmt*)parsetree;
+ int options =
+#if PG_VERSION_NUM >= 120000
+ parse_vacuum_opt(vac)
+#else
+ vac->options
+#endif
+ ;
+
#if PG_VERSION_NUM >= 110000
tblnames = vac->rels;
tblnames = list_make1(vac->relation);
#endif
- if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE))
+ if (options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE))
{
/* optionally with analyze */
op = CK_VACUUM;
if (tblnames == NIL)
relstatsInit();
}
- else if (vac->options & VACOPT_ANALYZE)
+ else if (options & VACOPT_ANALYZE)
{
op = CK_ANALYZE;