#include "postgres.h"
#include "pgstat.h"
+#include "miscadmin.h"
#include "access/transam.h"
#include "access/xact.h"
#include "catalog/namespace.h"
int nTables;
Oid *tables;
char *tableStr;
+ bool inited;
} TableList;
-static TableList excludeTables = {0, NULL, NULL};
-static TableList includeTables = {0, NULL, NULL};
+static TableList excludeTables = {0, NULL, NULL, false};
+static TableList includeTables = {0, NULL, NULL, false};
typedef struct OnlineAnalyzeTableStat {
Oid tableid;
if (!SplitIdentifierString(rawname, ',', &namelist))
goto cleanup;
+ /*
+ * follow work could be done only in normal processing because of
+ * accsess to system catalog
+ */
+ if (MyBackendId == InvalidBackendId || !IsUnderPostmaster ||
+ !IsTransactionState())
+ {
+ includeTables.inited = false;
+ excludeTables.inited = false;
+ return newval;
+ }
+
if (doit)
{
nOids = list_length(namelist);
#endif
+static void
+lateInit()
+{
+ TableList *tl[] = {&includeTables, &excludeTables};
+ int i;
+
+ if (MyBackendId == InvalidBackendId || !IsUnderPostmaster ||
+ !IsTransactionState())
+ return; /* we aren't in connected state */
+
+ for(i=0; i<lengthof(tl); i++)
+ {
+ TableList *tbl = tl[i];
+
+ if (tbl->inited == false)
+ tableListAssign(tbl->tableStr, true, tbl);
+ tbl->inited = true;
+ }
+}
+
static const char*
tableListShow(TableList *tbl)
{
int i,
len;
+ lateInit();
+
len = 1 /* \0 */ + tbl->nTables * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
ptr = val = palloc(len);
*ptr ='\0';
if (queryDesc->estate)
naffected = queryDesc->estate->es_processed;
+ lateInit();
+
#if PG_VERSION_NUM >= 90200
if (online_analyze_enable &&
(constval = isFastTruncateCall(queryDesc)) != NULL)
parsetree = pstmt->utilityStmt;
#endif
+ lateInit();
+
if (parsetree && online_analyze_enable)
{
if (IsA(parsetree, CreateTableAsStmt) &&