From 64ab7a9de74b8a56296e6cf6c71e83cc2f1405bc Mon Sep 17 00:00:00 2001 From: Dennis Kovalenko Date: Tue, 22 Oct 2024 15:30:04 +0300 Subject: [PATCH 1/8] Fix -Wunused-function warning produced by Clang (#1085) The fast_encode_date function is never used. It is safe to remove this function. --- src/backend/utils/adt/datetime.c | 38 -------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index c1750674d8e4..65dd09fdfef0 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -3859,44 +3859,6 @@ EncodeTimezone(char *str, int tz, int style) } -/* - * Convenience routine for encoding dates faster than sprintf does. - * tm is the timestamp structure, str is the string, pos is position in - * the string which we are at. Upon returning, it is set to the offset of the - * last character we set in str. - */ -inline static void -fast_encode_date(struct pg_tm * tm, char *str, int *pos) -{ - /* - * sprintf() is very slow so we just convert the numbers to - * a string manually. Since we allow dates in the range - * 4713 BC to 5874897 AD, we have to check for years - * with 7, 6 and 5 digits, being careful to not add - * leading zeros for those. We only zero pad to four digits. - */ - int y = (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1); - - if (y >= 1000000) - str[(*pos)++] = y / 1000000 % 10 + '0'; - if (y >= 100000) - str[(*pos)++] = y / 100000 % 10 + '0'; - if (y >= 10000) - str[(*pos)++] = y / 10000 % 10 + '0'; - - str[(*pos)++] = y/1000 % 10 + '0'; - str[(*pos)++] = y/100 % 10 + '0'; - str[(*pos)++] = y/10 % 10 + '0'; - str[(*pos)++] = y % 10 + '0'; - str[(*pos)++] = '-'; - str[(*pos)++] = tm->tm_mon/10 + '0'; - str[(*pos)++] = tm->tm_mon % 10 + '0'; - str[(*pos)++] = '-'; - str[(*pos)++] = tm->tm_mday/10 + '0'; - str[(*pos)++] = tm->tm_mday % 10 + '0'; - str[(*pos)] = '\0'; -} - /* EncodeDateOnly() * Encode date as local time. */ From 4be34c4fc88059c22e4fb5336ba9578b27ce9ebc Mon Sep 17 00:00:00 2001 From: Dennis Kovalenko Date: Wed, 23 Oct 2024 14:22:34 +0300 Subject: [PATCH 2/8] Fix -Wunused-variable and -Wunused-but-set-variable warnings produced by Clang (#1081) --- src/backend/access/appendonly/appendonly_compaction.c | 6 ------ src/backend/access/appendonly/appendonlywriter.c | 4 ---- src/backend/access/bitmap/bitmap.c | 3 --- src/backend/access/bitmap/bitmaputil.c | 2 -- src/backend/access/transam/xlog.c | 4 ++++ src/backend/commands/copy.c | 8 +------- src/backend/commands/explain.c | 2 -- src/backend/commands/matview.c | 3 +-- src/backend/executor/execUtils.c | 2 -- src/backend/executor/nodeHashjoin.c | 4 +--- src/backend/executor/nodeModifyTable.c | 2 -- src/backend/executor/nodeMotion.c | 7 ------- src/backend/executor/nodeSubplan.c | 2 -- src/backend/executor/spi.c | 7 ------- src/backend/optimizer/path/allpaths.c | 3 --- src/backend/optimizer/path/costsize.c | 6 ++---- src/backend/optimizer/path/joinpath.c | 5 ----- src/backend/optimizer/util/plancat.c | 3 --- src/backend/optimizer/util/var.c | 3 --- src/backend/parser/analyze.c | 5 ----- src/backend/parser/parse_utilcmd.c | 2 -- src/backend/postmaster/pgstat.c | 3 +-- 22 files changed, 10 insertions(+), 76 deletions(-) diff --git a/src/backend/access/appendonly/appendonly_compaction.c b/src/backend/access/appendonly/appendonly_compaction.c index 74ecba0033aa..c4be5a0a4f20 100644 --- a/src/backend/access/appendonly/appendonly_compaction.c +++ b/src/backend/access/appendonly/appendonly_compaction.c @@ -688,7 +688,6 @@ AppendOptimizedDropDeadSegments(Relation aorel, Bitmapset *segnos, AOVacuumRelSt void AppendOptimizedTruncateToEOF(Relation aorel, AOVacuumRelStats *vacrelstats) { - const char *relname; Relation pg_aoseg_rel; TupleDesc pg_aoseg_dsc; SysScanDesc aoscan; @@ -698,8 +697,6 @@ AppendOptimizedTruncateToEOF(Relation aorel, AOVacuumRelStats *vacrelstats) Assert(RelationStorageIsAO(aorel)); - relname = RelationGetRelationName(aorel); - /* * The algorithm below for choosing a target segment is not concurrent-safe. * Grab a lock to serialize. @@ -790,7 +787,6 @@ AppendOnlyCompact(Relation aorel, List *avoid_segnos, AOVacuumRelStats *vacrelstats) { - const char *relname; AppendOnlyInsertDesc insertDesc = NULL; FileSegInfo *fsinfo; Snapshot appendOnlyMetaDataSnapshot = RegisterSnapshot(GetCatalogSnapshot(InvalidOid)); @@ -798,8 +794,6 @@ AppendOnlyCompact(Relation aorel, Assert(RelationStorageIsAoRows(aorel)); Assert(Gp_role == GP_ROLE_EXECUTE || Gp_role == GP_ROLE_UTILITY); - relname = RelationGetRelationName(aorel); - /* Fetch under the write lock to get latest committed eof. */ fsinfo = GetFileSegInfo(aorel, appendOnlyMetaDataSnapshot, compaction_segno, true); diff --git a/src/backend/access/appendonly/appendonlywriter.c b/src/backend/access/appendonly/appendonlywriter.c index 40237af98775..bc6add58eade 100644 --- a/src/backend/access/appendonly/appendonlywriter.c +++ b/src/backend/access/appendonly/appendonlywriter.c @@ -144,7 +144,6 @@ void LockSegnoForWrite(Relation rel, int segno) { Relation pg_aoseg_rel; - TupleDesc pg_aoseg_dsc; SysScanDesc aoscan; HeapTuple tuple; Snapshot snapshot; @@ -171,7 +170,6 @@ LockSegnoForWrite(Relation rel, int segno) * size threshold (90% full). */ pg_aoseg_rel = table_open(segrelid, AccessShareLock); - pg_aoseg_dsc = RelationGetDescr(pg_aoseg_rel); /* * Obtain the snapshot that is taken at the beginning of the transaction. @@ -385,7 +383,6 @@ static int choose_segno_internal(Relation rel, List *avoid_segnos, choose_segno_mode mode) { Relation pg_aoseg_rel; - TupleDesc pg_aoseg_dsc; int i; int32 chosen_segno = -1; candidate_segment candidates[MAX_AOREL_CONCURRENCY]; @@ -443,7 +440,6 @@ choose_segno_internal(Relation rel, List *avoid_segnos, choose_segno_mode mode) * size threshold (90% full). */ pg_aoseg_rel = heap_open(segrelid, AccessShareLock); - pg_aoseg_dsc = RelationGetDescr(pg_aoseg_rel); /* * Scan through all the pg_aoseg (or pg_aocs) entries, and make note of diff --git a/src/backend/access/bitmap/bitmap.c b/src/backend/access/bitmap/bitmap.c index c6394a573764..f9206411d8c2 100644 --- a/src/backend/access/bitmap/bitmap.c +++ b/src/backend/access/bitmap/bitmap.c @@ -121,7 +121,6 @@ bmbuild(Relation heap, Relation index, IndexInfo *indexInfo) double reltuples; BMBuildState bmstate; IndexBuildResult *result; - TupleDesc tupDesc; if (indexInfo->ii_Concurrent) ereport(ERROR, @@ -135,8 +134,6 @@ bmbuild(Relation heap, Relation index, IndexInfo *indexInfo) errmsg("index \"%s\" already contains data", RelationGetRelationName(index)))); - tupDesc = RelationGetDescr(index); - /* initialize the bitmap index for MAIN_FORKNUM. */ _bitmap_init(index, RelationNeedsWAL(index), false); diff --git a/src/backend/access/bitmap/bitmaputil.c b/src/backend/access/bitmap/bitmaputil.c index f3021d864c3d..02c146458373 100644 --- a/src/backend/access/bitmap/bitmaputil.c +++ b/src/backend/access/bitmap/bitmaputil.c @@ -1035,7 +1035,6 @@ _bitmap_log_bitmapwords(Relation rel, xl_bm_bitmapwords xlBitmapWords; ListCell *lcp; ListCell *lcb; - bool init_page; int num_bm_pages = list_length(xl_bm_bitmapword_pages); int current_page = 0; @@ -1064,7 +1063,6 @@ _bitmap_log_bitmapwords(Relation rel, rdata_no = 1; /* Write per-page structs */ - init_page = init_first_page; forboth(lcp, xl_bm_bitmapword_pages, lcb, bitmapBuffers) { xl_bm_bitmapwords_perpage *xlBitmapwordsPage = lfirst(lcp); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8454627af996..cc0117efe312 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2155,7 +2155,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic) XLogRecPtr NewPageEndPtr = InvalidXLogRecPtr; XLogRecPtr NewPageBeginPtr; XLogPageHeader NewPage; +#ifdef WAL_DEBUG int npages = 0; +#endif LWLockAcquire(WALBufMappingLock, LW_EXCLUSIVE); @@ -2310,7 +2312,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic) XLogCtl->InitializedUpTo = NewPageEndPtr; +#ifdef WAL_DEBUG npages++; +#endif } LWLockRelease(WALBufMappingLock); diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index fe15160bb041..c69d6976af79 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -2852,16 +2852,12 @@ CopyToDispatch(CopyState cstate) { CopyStmt *stmt = glob_copystmt; TupleDesc tupDesc; - int num_phys_attrs; - int attr_count; FormData_pg_attribute *attr; CdbCopy *cdbCopy; uint64 processed = 0; tupDesc = cstate->rel->rd_att; attr = tupDesc->attrs; - num_phys_attrs = tupDesc->natts; - attr_count = list_length(cstate->attnumlist); /* We use fe_msgbuf as a per-row buffer regardless of copy_dest */ cstate->fe_msgbuf = makeStringInfo(); @@ -5738,8 +5734,7 @@ static bool NextCopyFromExecute(CopyState cstate, ExprContext *econtext, Datum *values, bool *nulls) { TupleDesc tupDesc; - AttrNumber num_phys_attrs, - attr_count; + AttrNumber num_phys_attrs; FormData_pg_attribute *attr; int i; copy_from_dispatch_row frame; @@ -5748,7 +5743,6 @@ NextCopyFromExecute(CopyState cstate, ExprContext *econtext, Datum *values, bool tupDesc = RelationGetDescr(cstate->rel); num_phys_attrs = tupDesc->natts; - attr_count = list_length(cstate->attnumlist); /* * The code below reads the 'copy_from_dispatch_row' struct, and only diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index f5c6b612a635..c5996c438842 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1487,7 +1487,6 @@ ExplainNode(PlanState *planstate, List *ancestors, ExplainState *es) { Plan *plan = planstate->plan; - PlanState *parentplanstate; ExecSlice *save_currentSlice = es->currentSlice; /* save */ const char *pname; /* node type name for text output */ const char *sname; /* node type name for non-text output */ @@ -1504,7 +1503,6 @@ ExplainNode(PlanState *planstate, List *ancestors, ExecSlice *parentSlice = NULL; /* Remember who called us. */ - parentplanstate = es->parentPlanState; es->parentPlanState = planstate; /* diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index c2916089e6ec..2cb901b52811 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -171,7 +171,6 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString, Oid relowner; Oid OIDNewHeap; DestReceiver *dest; - uint64 processed = 0; bool concurrent; LOCKMODE lockmode; char relpersistence; @@ -352,7 +351,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString, refreshClause = MakeRefreshClause(concurrent, stmt->skipData, stmt->relation); dataQuery->intoPolicy = matviewRel->rd_cdbpolicy; - processed = refresh_matview_datafill(dest, dataQuery, queryString, refreshClause); + refresh_matview_datafill(dest, dataQuery, queryString, refreshClause); /* Make the matview match the newly generated data. */ if (concurrent) diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index fc16ff89b793..e8cc7cf5c958 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -1509,13 +1509,11 @@ getGpExecIdentity(QueryDesc *queryDesc, void mppExecutorFinishup(QueryDesc *queryDesc) { EState *estate; - ExecSlice *currentSlice; int primaryWriterSliceIndex; /* caller must have switched into per-query memory context already */ estate = queryDesc->estate; - currentSlice = getCurrentSlice(estate, LocallyExecutingSliceIndex(estate)); primaryWriterSliceIndex = PrimaryWriterSliceIndex(estate); /* Teardown the Interconnect */ diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index c3f90080da89..149a22f0f3ee 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -1814,7 +1814,6 @@ ExecHashJoinReloadHashTable(HashJoinState *hjstate) TupleTableSlot *slot; uint32 hashvalue; int curbatch = hashtable->curbatch; - int nmoved = 0; #if 0 int orignbatch = hashtable->nbatch; #endif @@ -1851,8 +1850,7 @@ ExecHashJoinReloadHashTable(HashJoinState *hjstate) * NOTE: some tuples may be sent to future batches. Also, it is * possible for hashtable->nbatch to be increased here! */ - if (!ExecHashTableInsert(hashState, hashtable, slot, hashvalue)) - nmoved++; + ExecHashTableInsert(hashState, hashtable, slot, hashvalue); } /* diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 34be4c5e95b4..b5b5769c4bb3 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1766,7 +1766,6 @@ ExecSplitUpdate_Insert(ModifyTableState *mtstate, bool canSetTag) { ResultRelInfo *resultRelInfo; - Relation resultRelationDesc; bool partition_constraint_failed; TupleConversionMap *saved_tcs_map = NULL; PartitionTupleRouting *proute = mtstate->mt_partition_tuple_routing; @@ -1777,7 +1776,6 @@ ExecSplitUpdate_Insert(ModifyTableState *mtstate, * get information on the (current) result relation */ resultRelInfo = estate->es_result_relation_info; - resultRelationDesc = resultRelInfo->ri_RelationDesc; /* ensure slot is independent, consider e.g. EPQ */ ExecMaterializeSlot(slot); diff --git a/src/backend/executor/nodeMotion.c b/src/backend/executor/nodeMotion.c index 8b7b01e14b8c..7c0c86f5a0b3 100644 --- a/src/backend/executor/nodeMotion.c +++ b/src/backend/executor/nodeMotion.c @@ -665,7 +665,6 @@ ExecInitMotion(Motion *node, EState *estate, int eflags) ExecSlice *sendSlice; ExecSlice *recvSlice; SliceTable *sliceTable = estate->es_sliceTable; - PlanState *outerPlan; int parentIndex; /* @@ -786,12 +785,6 @@ ExecInitMotion(Motion *node, EState *estate, int eflags) outerPlanState(motionstate) = ExecInitNode(outerPlan(node), estate, eflags); } - /* - * initialize tuple type. no need to initialize projection info because - * this node doesn't do projections. - */ - outerPlan = outerPlanState(motionstate); - /* * Initialize result type and slot */ diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 14980f86e5ec..010dd9805837 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -1117,7 +1117,6 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext, QueryDesc *queryDesc bool needDtx; bool shouldDispatch = false; - volatile bool explainRecvStats = false; if (Gp_role == GP_ROLE_DISPATCH && planstate != NULL && @@ -1415,7 +1414,6 @@ PG_TRY(); if (planstate->instrument && planstate->instrument->need_cdb) { /* Jam stats into subplan's Instrumentation nodes. */ - explainRecvStats = true; cdbexplain_recvExecStats(planstate, ds->primaryResults, LocallyExecutingSliceIndex(queryDesc->estate), econtext->ecxt_estate->showstatctx); diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index d9e3e5cf6c61..442f9bf02f67 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -2738,7 +2738,6 @@ static int _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount) { int operation = queryDesc->operation; - int eflags; int res; _SPI_assign_query_mem(queryDesc); @@ -2818,12 +2817,6 @@ _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount) ResetUsage(); #endif - /* Select execution options */ - if (fire_triggers) - eflags = 0; /* default run-to-completion flags */ - else - eflags = EXEC_FLAG_SKIP_TRIGGERS; - PG_TRY(); { Oid relationOid = InvalidOid; /* relation that is modified */ diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 6cb6e4e9fe7e..944fb172a887 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -2851,7 +2851,6 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) CommonTableExpr *cte = NULL; double tuple_fraction = 0.0; CtePlanInfo *cteplaninfo; - List *pathkeys = NULL; PlannerInfo *subroot = NULL; RelOptInfo *sub_final_rel; Relids required_outer; @@ -3071,8 +3070,6 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) return; } - pathkeys = subroot->query_pathkeys; - /* Mark rel with estimated output rows, width, etc */ { double numsegments; diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 90a134ff2ed2..ff0546c58e29 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -5000,14 +5000,12 @@ adjust_selectivity_for_nulltest(Selectivity selec, if (IsA(clause, NullTest)) { - int nulltesttype; Node *node; Node *basenode; /* extract information */ - nulltesttype = ((NullTest *) clause)->nulltesttype; node = (Node *) ((NullTest *) clause)->arg; - + /* CONSIDER: is this really necessary? */ if (IsA(node, RelabelType)) basenode = (Node *) ((RelabelType *) node)->arg; @@ -5017,7 +5015,7 @@ adjust_selectivity_for_nulltest(Selectivity selec, if (IsA(basenode, Var)) { double nullfrac = 1 - selec; - + /* adjust selectivity according to test */ switch (((NullTest *) clause)->nulltesttype) { diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 66afd22ad1f2..b719d07e957c 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -2168,7 +2168,6 @@ select_cdb_redistribute_clauses(PlannerInfo *root, { List *result_list = NIL; bool isouterjoin = IS_OUTER_JOIN(jointype); - bool have_nonmergeable_joinclause = false; ListCell *l; foreach(l, restrictlist) @@ -2197,8 +2196,6 @@ select_cdb_redistribute_clauses(PlannerInfo *root, * reason to support constants is so we can do FULL JOIN ON * FALSE.) */ - if (!restrictinfo->clause || !IsA(restrictinfo->clause, Const)) - have_nonmergeable_joinclause = true; continue; /* not mergejoinable */ } @@ -2207,7 +2204,6 @@ select_cdb_redistribute_clauses(PlannerInfo *root, */ if (!clause_sides_match_join(restrictinfo, outerrel, innerrel)) { - have_nonmergeable_joinclause = true; continue; /* no good for these input relations */ } @@ -2236,7 +2232,6 @@ select_cdb_redistribute_clauses(PlannerInfo *root, if (EC_MUST_BE_REDUNDANT(restrictinfo->left_ec) || EC_MUST_BE_REDUNDANT(restrictinfo->right_ec)) { - have_nonmergeable_joinclause = true; continue; /* can't handle redundant eclasses */ } diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 7344d3cf4ed2..add3cd4f4d60 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -1628,7 +1628,6 @@ GetExtStatisticsName(Oid statOid) List * GetExtStatisticsKinds(Oid statOid) { - Form_pg_statistic_ext staForm; HeapTuple htup; Datum datum; bool isnull; @@ -1642,8 +1641,6 @@ GetExtStatisticsKinds(Oid statOid) if (!HeapTupleIsValid(htup)) elog(ERROR, "cache lookup failed for statistics object %u", statOid); - staForm = (Form_pg_statistic_ext) GETSTRUCT(htup); - datum = SysCacheGetAttr(STATEXTOID, htup, Anum_pg_statistic_ext_stxkind, &isnull); arr = DatumGetArrayTypeP(datum); diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index 21b7ccc287ae..af686a01e81c 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -947,16 +947,13 @@ flatten_join_alias_vars_mutator(Node *node, RowExpr *rowexpr; List *fields = NIL; List *colnames = NIL; - AttrNumber attnum; ListCell *lv; ListCell *ln; - attnum = 0; Assert(list_length(rte->joinaliasvars) == list_length(rte->eref->colnames)); forboth(lv, rte->joinaliasvars, ln, rte->eref->colnames) { newvar = (Node *) lfirst(lv); - attnum++; /* Ignore dropped columns */ if (newvar == NULL) continue; diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index d849ddf1c5f8..2e8a1f13e721 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -2290,11 +2290,6 @@ transformSetOperationTree_internal(ParseState *pstate, SelectStmt *stmt, { /* Process an internal node (set operation node) */ SetOperationStmt *op = makeNode(SetOperationStmt); - const char *context; - - context = (stmt->op == SETOP_UNION ? "UNION" : - (stmt->op == SETOP_INTERSECT ? "INTERSECT" : - "EXCEPT")); op->op = stmt->op; op->all = stmt->all; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index fccb237b42f9..6ac85d726900 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -2740,7 +2740,6 @@ transformDistributedBy(ParseState *pstate, if (cxt->inhRelations) { - bool found = false; /* try inherited tables */ ListCell *inher; @@ -2786,7 +2785,6 @@ transformDistributedBy(ParseState *pstate, "table. ", inhname), errhint("The 'DISTRIBUTED BY' clause determines the distribution of data." " Make sure column(s) chosen are the optimal data distribution key to minimize skew."))); - found = true; break; } } diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index dc8f4c7dbdb5..578c31a67be6 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -4820,7 +4820,6 @@ pgstat_combine_one_qe_result(List **oidList, struct pg_result *pgresult, { int arrayLen; PgStatTabRecordFromQE *records; - PgStat_SubXactStatus *xact_state; PgStat_TableStatus *pgstat_info; PgStat_TableXactStatus *trans; @@ -4830,7 +4829,7 @@ pgstat_combine_one_qe_result(List **oidList, struct pg_result *pgresult, * If this is the first rel to be modified at the current nest level, * we first have to push a transaction stack entry. */ - xact_state = get_tabstat_stack_level(nest_level); + get_tabstat_stack_level(nest_level); arrayLen = pgresult->extraslen / sizeof(PgStatTabRecordFromQE); records = (PgStatTabRecordFromQE *) pgresult->extras; From 41ad71f2a3d8a96fe3346f68d916611e04bce52d Mon Sep 17 00:00:00 2001 From: bhari Date: Thu, 16 May 2024 09:47:07 +0530 Subject: [PATCH 3/8] Fallback to planner if a function in 'from' clause uses 'WITH ORDINALITY' (#17477) In https://github.com/greenplum-db/gpdb/issues/17461, the following sql crashes orca during optimization: `SELECT * FROM jsonb_array_elements('["c", "a", "b"]'::jsonb) WITH ORDINALITY;` That is because, Orca currently doesn't support "WITH ORDINALITY". Sometimes orca will fallback with the message: Query-to-DXL Translation: No variable entry found due to incorrect normalization of query. Orca needs work to support this, so we want to fall back for now. Change: If "WITH ORDINALITY" is used, we will now fallback to postgres-based planner with explicit error message like below. `DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: WITH ORDINALITY` (cherry picked from commit 99f0c82) --- src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp | 6 ++++++ src/test/regress/expected/qp_orca_fallback.out | 8 ++++++++ .../regress/expected/qp_orca_fallback_optimizer.out | 10 ++++++++++ src/test/regress/sql/qp_orca_fallback.sql | 3 +++ 4 files changed, 27 insertions(+) diff --git a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp index ac8266a022ac..59d8ba219b13 100644 --- a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp +++ b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp @@ -3344,6 +3344,12 @@ CTranslatorQueryToDXL::TranslateFromClauseToDXL(Node *node) GPOS_WSZ_LIT("LATERAL")); } + if (rte->funcordinality) + { + GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature, + GPOS_WSZ_LIT("WITH ORDINALITY")); + } + switch (rte->rtekind) { default: diff --git a/src/test/regress/expected/qp_orca_fallback.out b/src/test/regress/expected/qp_orca_fallback.out index 3c2b6fd24345..4a20d790be51 100644 --- a/src/test/regress/expected/qp_orca_fallback.out +++ b/src/test/regress/expected/qp_orca_fallback.out @@ -290,3 +290,11 @@ select array_agg(a order by b) (1 row) reset optimizer_enable_orderedagg; +-- Orca should fallback if a function in 'from' clause uses 'WITH ORDINALITY' +SELECT * FROM jsonb_array_elements('["b", "a"]'::jsonb) WITH ORDINALITY; + value | ordinality +-------+------------ + "b" | 1 + "a" | 2 +(2 rows) + diff --git a/src/test/regress/expected/qp_orca_fallback_optimizer.out b/src/test/regress/expected/qp_orca_fallback_optimizer.out index 684115a56071..17d9b98dd700 100644 --- a/src/test/regress/expected/qp_orca_fallback_optimizer.out +++ b/src/test/regress/expected/qp_orca_fallback_optimizer.out @@ -346,3 +346,13 @@ DETAIL: Falling back to Postgres-based planner because GPORCA does not support (1 row) reset optimizer_enable_orderedagg; +-- Orca should fallback if a function in 'from' clause uses 'WITH ORDINALITY' +SELECT * FROM jsonb_array_elements('["b", "a"]'::jsonb) WITH ORDINALITY; +INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner +DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: WITH ORDINALITY + value | ordinality +-------+------------ + "b" | 1 + "a" | 2 +(2 rows) + diff --git a/src/test/regress/sql/qp_orca_fallback.sql b/src/test/regress/sql/qp_orca_fallback.sql index 98085e028d5c..038eeeb06308 100644 --- a/src/test/regress/sql/qp_orca_fallback.sql +++ b/src/test/regress/sql/qp_orca_fallback.sql @@ -128,3 +128,6 @@ set optimizer_enable_orderedagg=off; select array_agg(a order by b) from (values (1,4),(2,3),(3,1),(4,2)) v(a,b); reset optimizer_enable_orderedagg; + +-- Orca should fallback if a function in 'from' clause uses 'WITH ORDINALITY' +SELECT * FROM jsonb_array_elements('["b", "a"]'::jsonb) WITH ORDINALITY; From d15eadea86602b41882928d46241d1e7f3db0e93 Mon Sep 17 00:00:00 2001 From: Roman Eskin Date: Thu, 4 Apr 2024 21:47:32 +1000 Subject: [PATCH 4/8] Fix panic with 'stuck spinlock' during crash recovery tests (#901) Problem: Isolation crash recovery tests (for example, uao_crash_compaction_column, crash_recovery_dtm, etc.) failed with 'stuck spinlock' panic with very low reproduction rate. Cause: Problem happened in the following case: 1. During the test, a backend process was forced into a panic (according to test scenario). 2. At the very same moment, the background writer process called 'SIMPLE_FAULT_INJECTOR("fault_in_background_writer_main")', he did it regularly from the loop in 'BackgroundWriterMain'. The bg writer acquired the spinlock inside the fault injector, but before it released it... 3. Postmaster started to send the SIGQUIT signal to all child processes. 4. Background writer process received SIGQUIT and halted its execution without releasing the spinlock. 5. In the background writer process, a handler for the SIGQUIT signal was invoked - 'bg_quickdie'. And 'bg_quickdie' called 'SIMPLE_FAULT_INJECTOR("fault_in_background_writer_quickdie");'. As the spinlock was not released, 'bg_quickdie' hanged on the spinlock. 6. Postmaster failed to wait child processes completion. And after timeout it tried to check 'SIMPLE_FAULT_INJECTOR("postmaster_server_loop_no_sigkill")' and hanged on the same spinlock as well. 7. Finally, both postmaster and 'bg_quickdie' failed with 'stuck spinlock' panic. Fix: The general rule would be that it is NOT allowed to access the fault injector from the postmaster process or from any SIGQUIT handler of child processes when the system is resetting after the crash of some backend. It is so because during reset postmaster terminates child processes, and it might terminate some process when the process has acquired the spinlock of the fault injector, but hasn't released it yet. So, subsequent calls to the fault injector api from postmaster or any SIGQUIT handler will lead to deadlock. Only 'doomed' processes can still call the fault injector api, as they will soon be terminated anyway. According to written above, following changes are made: 1. Access to the fault injector during a reset is removed from 'bg_quickdie' and postmaster's ServerLoop. 2. The fts_segment_reset test and related code are redesigned. Now, instead of sleeping for a delay defined by the test in 'bg_quickdie', postmaster sends SIGSTOP to the bg writer, and starts a timer for the delay. Once the delay elapses, the timer handler sends SIGCONT and SIGQUIT to the bg writer. This logic is triggered if the postmaster detects the new fault "postmaster_delay_termination_bg_writer" (which is a replacement for "fault_in_background_writer_quickdie" and "postmaster_server_loop_no_sigkill"). This fault is checked only when the postmaster is in the PM_RUN state. So it should be safe to check for it. New tests specific to this issue are not added because of the unstable nature of the problem. Changes from original commit: 1. Add a NULL check to timeout.c (borrowed from GPDB 6) 2. Changed comments. (cherry picked from commit dae2f0851da4a18cccdfb1f4c2b5d1dd552b806c) --- src/backend/postmaster/bgwriter.c | 2 - src/backend/postmaster/postmaster.c | 105 ++++++++++++++++-- src/backend/utils/misc/timeout.c | 6 +- .../isolation2/expected/fts_segment_reset.out | 19 +--- src/test/isolation2/sql/fts_segment_reset.sql | 12 +- 5 files changed, 109 insertions(+), 35 deletions(-) diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index 8391660ed3a7..855ec9db26af 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -391,8 +391,6 @@ BackgroundWriterMain(void) static void bg_quickdie(SIGNAL_ARGS) { - SIMPLE_FAULT_INJECTOR("fault_in_background_writer_quickdie"); - /* * We DO NOT want to run proc_exit() or atexit() callbacks -- we're here * because shared memory may be corrupted, so we don't want to try to diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index f29b5c9d5bc0..4af867f5f9b2 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -164,6 +164,9 @@ bool am_mirror = false; /* GPDB specific flag to handle deadlocks during parallel segment start. */ volatile bool *pm_launch_walreceiver = NULL; +/* This is set by a test to simulate long RESET state. */ +static int delay_bg_writer_termination_sec = 0; + /* * Possible types of a backend. Beyond being the possible bkend_type values in * struct bkend, these are OR-able request flag bits for SignalSomeChildren() @@ -498,6 +501,7 @@ static void sigusr1_handler(SIGNAL_ARGS); static void process_startup_packet_die(SIGNAL_ARGS); static void process_startup_packet_quickdie(SIGNAL_ARGS); static void dummy_handler(SIGNAL_ARGS); +static void TerminateBgWriterHandler(void); static void StartupPacketTimeoutHandler(void); static void CleanupBackend(int pid, int exitstatus); static bool CleanupBackgroundWorker(int pid, int exitstatus); @@ -803,6 +807,12 @@ PostmasterMain(int argc, char *argv[]) */ InitializeGUCOptions(); + /* + * Note: MyLatch is still not initialized for postmaster, + * so it will not be set during timeout signal handler + */ + InitializeTimeouts(); + opterr = 1; /* @@ -1916,6 +1926,7 @@ ServerLoop(void) int nSockets; time_t last_lockfile_recheck_time, last_touch_time; + bool postmaster_no_sigkill = false; last_lockfile_recheck_time = last_touch_time = time(NULL); @@ -2026,6 +2037,44 @@ ServerLoop(void) } } +#ifdef FAULT_INJECTOR + if (pmState == PM_RUN) + { + /* + * Code below is for test purposes only. If a fault is set, it + * will delay the termination of the background writer process for + * the amount of seconds desired by the test. + * + * Important note: it is NOT allowed to access the fault injector + * from Postmaster process or from any SIGQUIT handler of child + * processes when the system is resetting after the crash of some + * backend. Reason: during reset Postmaster kills child processes, + * and it might kill some process when the process has acquired + * the spin lock of the fault injector, but hasn't released it + * yet. So, subsequent call of the fault injector api from + * Postmaster or any SIGQUIT handler will lead to deadlock. Only + * 'doomed' processes can still call the fault injector api, as + * they will soon be terminated anyway. Thus, the fault injector + * is accessed only when the Postmaster state is PM_RUN. + */ + if (SIMPLE_FAULT_INJECTOR("postmaster_delay_termination_bg_writer") == + FaultInjectorTypeSkip) + { + /* + * Let the background writer sleep a little bit larger than + * the FTS retry window (which is gp_fts_probe_retries * 1 sec). + */ + delay_bg_writer_termination_sec = gp_fts_probe_retries + 2; + postmaster_no_sigkill = true; + } + else + { + delay_bg_writer_termination_sec = 0; + postmaster_no_sigkill = false; + } + } +#endif + /* If we have lost the log collector, try to start a new one */ if (SysLoggerPID == 0 && Logging_collector) SysLoggerPID = SysLogger_Start(); @@ -2123,8 +2172,7 @@ ServerLoop(void) AbortStartTime != 0 && (now - AbortStartTime) >= SIGKILL_CHILDREN_AFTER_SECS) { -#ifdef FAULT_INJECTOR - if (SIMPLE_FAULT_INJECTOR("postmaster_server_loop_no_sigkill") == FaultInjectorTypeSkip) + if (postmaster_no_sigkill) { /* * This prevents sending SIGKILL to child processes for testing purpose. @@ -2135,7 +2183,7 @@ ServerLoop(void) pg_usleep(100000L); continue; } -#endif + /* We were gentle with them before. Not anymore */ TerminateChildren(SIGKILL); /* reset flag so we don't SIGKILL again */ @@ -4029,11 +4077,37 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) BgWriterPID = 0; else if (BgWriterPID != 0 && take_action) { - ereport(DEBUG2, - (errmsg_internal("sending %s to process %d", - (SendStop ? "SIGSTOP" : "SIGQUIT"), - (int) BgWriterPID))); - signal_child(BgWriterPID, (SendStop ? SIGSTOP : SIGQUIT)); + if (delay_bg_writer_termination_sec == 0) + { + ereport(DEBUG2, + (errmsg_internal("sending %s to process %d", + (SendStop ? "SIGSTOP" : "SIGQUIT"), + (int) BgWriterPID))); + signal_child(BgWriterPID, (SendStop ? SIGSTOP : SIGQUIT)); + } + else + { + /* + * Code below is only for test purposes and should not be invoked + * under normal conditions. It will delay the termination of the + * background writer process. + * + * In order to delay the termination of the background writer + * process - send SIGSTOP to the bg writer process and start a + * timer that will wake up and then immediately terminate it. + */ + static TimeoutId id = 0; + + ereport(DEBUG2, + (errmsg_internal("sending SIGSTOP to process %d and starting timer", + (int) BgWriterPID))); + signal_child(BgWriterPID, SIGSTOP); + + if (id == 0) + id = RegisterTimeout(USER_TIMEOUT, TerminateBgWriterHandler); + + enable_timeout_after(id, delay_bg_writer_termination_sec * 1000); + } } /* Take care of the checkpointer too */ @@ -5881,6 +5955,21 @@ dummy_handler(SIGNAL_ARGS) { } +/* + * Terminate stopped background writer process (should be invoked only + * during test). + */ +static void +TerminateBgWriterHandler() +{ + ereport(DEBUG2, + (errmsg_internal("sending SIGCONT and SIGQUIT to process %d", + (int) BgWriterPID))); + + signal_child(BgWriterPID, SIGCONT); + signal_child(BgWriterPID, SIGQUIT); +} + /* * Timeout while processing startup packet. * As for process_startup_packet_die(), we clean up and exit(1). diff --git a/src/backend/utils/misc/timeout.c b/src/backend/utils/misc/timeout.c index c76f23acfcb5..10a722496b9e 100644 --- a/src/backend/utils/misc/timeout.c +++ b/src/backend/utils/misc/timeout.c @@ -275,9 +275,11 @@ handle_sig_alarm(SIGNAL_ARGS) /* * SIGALRM is always cause for waking anything waiting on the process - * latch. + * latch. Cope with MyLatch not being there, as the startup process also + * uses this signal handler. */ - SetLatch(MyLatch); + if (MyLatch) + SetLatch(MyLatch); /* * Fire any pending timeouts, but only if we're enabled to do so. diff --git a/src/test/isolation2/expected/fts_segment_reset.out b/src/test/isolation2/expected/fts_segment_reset.out index d8a49af69582..c9f19ebac626 100644 --- a/src/test/isolation2/expected/fts_segment_reset.out +++ b/src/test/isolation2/expected/fts_segment_reset.out @@ -13,7 +13,7 @@ -- to restart, and potentially makes FTS think it's in "recovery not -- in progress" stage and promote the mirror, we would need the FTS -- to make that decision a bit less frequently. -!\retcode gpconfig -c gp_fts_probe_retries -v 15 --coordinatoronly; +!\retcode gpconfig -c gp_fts_probe_retries -v 15; (exited with code 0) !\retcode gpstop -u; (exited with code 0) @@ -22,14 +22,8 @@ -- This number is selected to be larger than the 15-second retry window -- which makes a meaningful test, meanwhile reduce the chance that FTS sees -- a "recovery not in progress" primary as much as possible. -select gp_inject_fault('fault_in_background_writer_quickdie', 'sleep', '', '', '', 1, 1, 17, dbid) from gp_segment_configuration where role = 'p' and content = 0; - gp_inject_fault ------------------ - Success: -(1 row) - --- Do not let the postmaster send SIGKILL to the bgwriter -select gp_inject_fault_infinite('postmaster_server_loop_no_sigkill', 'skip', dbid) from gp_segment_configuration where role = 'p' and content = 0; +-- It also will not let the postmaster send SIGKILL to the bgwriter. +select gp_inject_fault_infinite('postmaster_delay_termination_bg_writer', 'skip', dbid) from gp_segment_configuration where role = 'p' and content = 0; gp_inject_fault_infinite -------------------------- Success: @@ -74,12 +68,7 @@ select dbid, role, preferred_role, status from gp_segment_configuration where co 5 | m | m | u (2 rows) -select gp_inject_fault('postmaster_server_loop_no_sigkill', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; - gp_inject_fault ------------------ - Success: -(1 row) -select gp_inject_fault('fault_in_background_writer_quickdie', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; +select gp_inject_fault('postmaster_delay_termination_bg_writer', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; gp_inject_fault ----------------- Success: diff --git a/src/test/isolation2/sql/fts_segment_reset.sql b/src/test/isolation2/sql/fts_segment_reset.sql index d784990dbc9f..632367678640 100644 --- a/src/test/isolation2/sql/fts_segment_reset.sql +++ b/src/test/isolation2/sql/fts_segment_reset.sql @@ -12,18 +12,15 @@ -- to restart, and potentially makes FTS think it's in "recovery not -- in progress" stage and promote the mirror, we would need the FTS -- to make that decision a bit less frequently. -!\retcode gpconfig -c gp_fts_probe_retries -v 15 --coordinatoronly; +!\retcode gpconfig -c gp_fts_probe_retries -v 15; !\retcode gpstop -u; -- Let the background writer sleep 17 seconds to delay the resetting. -- This number is selected to be larger than the 15-second retry window -- which makes a meaningful test, meanwhile reduce the chance that FTS sees -- a "recovery not in progress" primary as much as possible. -select gp_inject_fault('fault_in_background_writer_quickdie', 'sleep', '', '', '', 1, 1, 17, dbid) -from gp_segment_configuration where role = 'p' and content = 0; - --- Do not let the postmaster send SIGKILL to the bgwriter -select gp_inject_fault_infinite('postmaster_server_loop_no_sigkill', 'skip', dbid) +-- It also will not let the postmaster send SIGKILL to the bgwriter. +select gp_inject_fault_infinite('postmaster_delay_termination_bg_writer', 'skip', dbid) from gp_segment_configuration where role = 'p' and content = 0; -- Now bring down primary of seg0. There're a lot of ways to do that, in order @@ -48,8 +45,7 @@ from gp_segment_configuration where role = 'p' AND content = 0; select gp_request_fts_probe_scan(); select dbid, role, preferred_role, status from gp_segment_configuration where content = 0; -select gp_inject_fault('postmaster_server_loop_no_sigkill', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; -select gp_inject_fault('fault_in_background_writer_quickdie', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; +select gp_inject_fault('postmaster_delay_termination_bg_writer', 'reset', dbid) from gp_segment_configuration where role = 'p' and content = 0; -- The only table that should have been created successfully drop table fts_reset_t3; From 03a9bb32c0c62ce9b5a7de9cc4f33998b1267cd7 Mon Sep 17 00:00:00 2001 From: Roman Eskin Date: Tue, 8 Oct 2024 23:36:21 +1000 Subject: [PATCH 5/8] Keep original ccnt into query structure (#1064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Previous approach to identify a query that is currently being executed was based on the global gp_command_count variable. Query identification is required by the monitoring extensions to track the execution process. But gp_command_count is incremented on each new query. So, in case of a complex query with initplans, monitoring extensions were not able to track the execution of the query after the initplan execution had been done, because gp_command_count was already changed comparing to its value at the query start. To address this issue, monitoring extensions hacked the gp_command_count value, which is dispatched from the QD to the QEs (replaced it with the value stored before the init plan execution). But it led to other problems, for ex. hanging of query execution if IC proxy is enabled or if the plan had Shared Input scans, as these features also relied on the gp_command_count value. Fix: This patch adds a support of a query monitoring into the GPDB core. The approach uses already existing (but not previously used in the GPDB core) field queryCommandId of PGPROC for command identification. The handling for queryCommandId is reworked: queryCommandId is set to gp_command_count every time gp_command_count is incremented on the dispatcher (that’s old behavior, it is not changed). QueryDesc now contains 1 new field (filled in CreateQueryDesc()) command_id - the updated value of MyProc->queryCommandId after its increment. At the Dispatcher side: Executor switches MyProc->queryCommandId to the command_id of the QueryDesc at the beginning of ExecutorStart(), ExecutorRun(), ExecutorFinish(), ExecutorEnd(), and back to the preceding value at their end. For utility commands, increment_command_count() is added in the ProcessUtility(). At the end of ProcessUtility(), the value of MyProc->queryCommandId is restored to preceding value. MyProc->queryCommandId is added to the query message dispatched to the executors (instead of gp_command_count). gp_command_count is not sent to the QEs. At the Executor side, backend acquires proper queryCommandId from the message dispatched from the query dispatcher. On the QE the gp_command_count is set to be equal to the queryCommandId. Most parts of the code, that used gp_command_count, now use queryCommandId (some places still use gp_command_count, like for ex. RunawayCleaner. They require additional analysis and possibly would be updated later). After this change, monitoring extension should use MyProc->queryCommandId as the ccnt for the query identification instead of the gp_command_count. gp_command_count still exists as a global counter at the QD, that is used to assign a new value to the queryCommandId at the start of query execution. Ticket: ADBDEV-6375 (cherry picked from commit 7ee713d131ac3d1fa51fd1288790b9d0b5bae269) Changes comparing to the original commit: 1. ABI check ignore file is moved to a folder with actual base version; 2. expected files for the test are updated because of GPDB 7 differences in some queries execution; 3. matchsubs are updated in the test because of GPDB 7 differences; 4. gpperfmon is removed in GPDB 7, so changes in gpperfmon are omitted; 5. external_set_env_vars_ext() is now located in a different file, so the respective change is done there; 6. sisc_lockname() doesn't exist anymore, so this change is omitted; 7. in get_shareinput_reference() gp_command_count is replaced with MyProc->queryCommandId; 8. changes from CheckForResetSession() are now done in GpResetSessionIfNeeded(), as CheckForResetSession() through the times was transormed into GpDropTempTables(), which in turn was transformed into GpResetSessionIfNeeded(). --- .../7.2.0_arenadata5/postgres.types.ignore | 1 + src/backend/access/external/url.c | 5 +- src/backend/cdb/cdbdtxcontextinfo.c | 3 +- src/backend/cdb/cdbthreadlog.c | 4 +- src/backend/cdb/cdbvars.c | 6 +- src/backend/cdb/dispatcher/cdbdisp_query.c | 16 +- src/backend/cdb/dispatcher/cdbgang.c | 1 + src/backend/cdb/endpoint/cdbendpointutils.c | 4 +- src/backend/cdb/motion/ic_proxy_backend.c | 3 +- src/backend/cdb/motion/ic_udpifc.c | 3 +- src/backend/executor/execMain.c | 116 ++- src/backend/executor/instrument.c | 3 +- src/backend/executor/nodeShareInputScan.c | 4 +- src/backend/gpopt/utils/COptTasks.cpp | 3 +- src/backend/postmaster/backoff.c | 2 +- src/backend/storage/lmgr/proc.c | 4 +- src/backend/tcop/postgres.c | 13 +- src/backend/tcop/pquery.c | 29 +- src/backend/tcop/utility.c | 36 + src/backend/utils/error/elog.c | 10 +- src/backend/utils/misc/ps_status.c | 5 +- src/backend/utils/misc/test/ps_status_test.c | 3 - .../utils/workfile_manager/workfile_mgr.c | 5 +- src/include/executor/execdesc.h | 1 + src/include/storage/proc.h | 3 +- src/include/utils/session_state.h | 2 +- src/test/regress/expected/gp_query_id.out | 863 ++++++++++++++++++ .../expected/gp_query_id_optimizer.out | 863 ++++++++++++++++++ src/test/regress/greenplum_schedule | 2 + src/test/regress/sql/gp_query_id.sql | 137 +++ 30 files changed, 2091 insertions(+), 59 deletions(-) create mode 100644 .abi-check/7.2.0_arenadata5/postgres.types.ignore create mode 100644 src/test/regress/expected/gp_query_id.out create mode 100644 src/test/regress/expected/gp_query_id_optimizer.out create mode 100644 src/test/regress/sql/gp_query_id.sql diff --git a/.abi-check/7.2.0_arenadata5/postgres.types.ignore b/.abi-check/7.2.0_arenadata5/postgres.types.ignore new file mode 100644 index 000000000000..033e1b25bd8d --- /dev/null +++ b/.abi-check/7.2.0_arenadata5/postgres.types.ignore @@ -0,0 +1 @@ +struct QueryDesc diff --git a/src/backend/access/external/url.c b/src/backend/access/external/url.c index 59080b954444..b8a8d04efd82 100644 --- a/src/backend/access/external/url.c +++ b/src/backend/access/external/url.c @@ -22,6 +22,7 @@ #include "libpq/libpq-be.h" #include "miscadmin.h" #include "postmaster/postmaster.h" /* postmaster port */ +#include "storage/proc.h" #include "tcop/tcopprot.h" #include "utils/builtins.h" #include "utils/guc.h" @@ -109,9 +110,9 @@ external_set_env_vars_ext(extvar_t *extvar, char *uri, bool csv, char *escape, c * "session id"-"command id" to identify the transaction. */ if (!getDistributedTransactionIdentifier(extvar->GP_XID)) - sprintf(extvar->GP_XID, "%u-%.10u", gp_session_id, gp_command_count); + sprintf(extvar->GP_XID, "%u-%.10u", gp_session_id, MyProc->queryCommandId); - sprintf(extvar->GP_CID, "%x", gp_command_count); + sprintf(extvar->GP_CID, "%x", MyProc->queryCommandId); sprintf(extvar->GP_SN, "%x", scancounter); sprintf(extvar->GP_SEGMENT_ID, "%d", GpIdentity.segindex); sprintf(extvar->GP_SEG_PORT, "%d", PostPortNumber); diff --git a/src/backend/cdb/cdbdtxcontextinfo.c b/src/backend/cdb/cdbdtxcontextinfo.c index 40b93e29792e..b9bc61881a37 100644 --- a/src/backend/cdb/cdbdtxcontextinfo.c +++ b/src/backend/cdb/cdbdtxcontextinfo.c @@ -21,6 +21,7 @@ #include "cdb/cdbvars.h" #include "cdb/cdbtm.h" #include "access/xact.h" +#include "storage/proc.h" #include "utils/guc.h" #include "utils/session_state.h" @@ -62,7 +63,7 @@ DtxContextInfo_CreateOnCoordinator(DtxContextInfo *dtxContextInfo, bool inCursor AssertImply(inCursor, dtxContextInfo->distributedXid != InvalidDistributedTransactionId && - gp_command_count == MySessionState->latestCursorCommandId); + MyProc->queryCommandId == MySessionState->latestCursorCommandId); dtxContextInfo->cursorContext = inCursor; dtxContextInfo->nestingLevel = GetCurrentTransactionNestLevel(); diff --git a/src/backend/cdb/cdbthreadlog.c b/src/backend/cdb/cdbthreadlog.c index 15fbd064e257..700258436560 100644 --- a/src/backend/cdb/cdbthreadlog.c +++ b/src/backend/cdb/cdbthreadlog.c @@ -23,6 +23,7 @@ #include "miscadmin.h" #include "pgtime.h" #include "postmaster/syslogger.h" +#include "storage/proc.h" #ifndef _WIN32 @@ -166,7 +167,8 @@ write_log(const char *fmt,...) sprintf(tempbuf, "%d", MyProcPid); strcat(logprefix, tempbuf); /* pid */ strcat(logprefix, "|"); - sprintf(tempbuf, "con%d cmd%d", gp_session_id, gp_command_count); + sprintf(tempbuf, "con%d cmd%d", + gp_session_id, MyProc != NULL ? MyProc->queryCommandId : 0); strcat(logprefix, tempbuf); strcat(logprefix, "|"); diff --git a/src/backend/cdb/cdbvars.c b/src/backend/cdb/cdbvars.c index 3e4dfbb45c47..d29a66ab5e2a 100644 --- a/src/backend/cdb/cdbvars.c +++ b/src/backend/cdb/cdbvars.c @@ -653,7 +653,7 @@ gpvars_check_rg_query_fixed_mem(int *newval, void **extra, GucSource source) /* * increment_command_count * Increment gp_command_count. If the new command count is 0 or a negative number, reset it to 1. - * And keep MyProc->queryCommandId synced with gp_command_count. + * And update MyProc->queryCommandId. */ void increment_command_count() @@ -662,10 +662,6 @@ increment_command_count() if (gp_command_count <= 0) gp_command_count = 1; - /* - * No need to maintain MyProc->queryCommandId elsewhere, we guarantee - * they are always synced here. - */ MyProc->queryCommandId = gp_command_count; } diff --git a/src/backend/cdb/dispatcher/cdbdisp_query.c b/src/backend/cdb/dispatcher/cdbdisp_query.c index 0f7b36e60aee..820fcf75cb8a 100644 --- a/src/backend/cdb/dispatcher/cdbdisp_query.c +++ b/src/backend/cdb/dispatcher/cdbdisp_query.c @@ -29,6 +29,7 @@ #include "catalog/namespace.h" /* for GetTempNamespaceState() */ #include "nodes/execnodes.h" #include "pgstat.h" +#include "storage/proc.h" #include "tcop/tcopprot.h" #include "utils/datum.h" #include "utils/guc.h" @@ -82,6 +83,7 @@ typedef struct DispatchCommandQueryParms */ const char *strCommand; int strCommandlen; + int queryCommandId; char *serializedPlantree; int serializedPlantreelen; char *serializedQueryDispatchDesc; @@ -259,7 +261,7 @@ CdbDispatchPlan(struct QueryDesc *queryDesc, */ if (queryDesc->extended_query) { - verify_shared_snapshot_ready(gp_command_count); + verify_shared_snapshot_ready(MyProc->queryCommandId); } cdbdisp_dispatchX(queryDesc, planRequiresTxn, cancelOnError); @@ -560,6 +562,7 @@ cdbdisp_buildCommandQueryParms(const char *strCommand, int flags) pQueryParms = palloc0(sizeof(*pQueryParms)); pQueryParms->strCommand = strCommand; + pQueryParms->queryCommandId = MyProc->queryCommandId; pQueryParms->serializedQueryDispatchDesc = NULL; pQueryParms->serializedQueryDispatchDesclen = 0; @@ -631,6 +634,7 @@ cdbdisp_buildUtilityQueryParms(struct Node *stmt, pQueryParms = palloc0(sizeof(*pQueryParms)); pQueryParms->strCommand = PointerIsValid(debug_query_string) ? debug_query_string : ""; + pQueryParms->queryCommandId = MyProc->queryCommandId; pQueryParms->serializedPlantree = serializedPlantree; pQueryParms->serializedPlantreelen = serializedPlantree_len; pQueryParms->serializedQueryDispatchDesc = serializedQueryDispatchDesc; @@ -690,6 +694,7 @@ cdbdisp_buildPlanQueryParms(struct QueryDesc *queryDesc, sddesc = serializeNode((Node *) queryDesc->ddesc, &sddesc_len, NULL /* uncompressed_size */ ); pQueryParms->strCommand = queryDesc->sourceText; + pQueryParms->queryCommandId = MyProc->queryCommandId; pQueryParms->serializedPlantree = splan; pQueryParms->serializedPlantreelen = splan_len; pQueryParms->serializedQueryDispatchDesc = sddesc; @@ -892,6 +897,7 @@ buildGpQueryString(DispatchCommandQueryParms *pQueryParms, const char *dtxContextInfo = pQueryParms->serializedDtxContextInfo; int dtxContextInfo_len = pQueryParms->serializedDtxContextInfolen; int64 currentStatementStartTimestamp = GetCurrentStatementStartTimestamp(); + int queryCommandId = pQueryParms->queryCommandId; Oid sessionUserId = GetSessionUserId(); Oid outerUserId = GetOuterUserId(); Oid currentUserId = GetUserId(); @@ -934,7 +940,7 @@ buildGpQueryString(DispatchCommandQueryParms *pQueryParms, total_query_len = 1 /* 'M' */ + sizeof(len) /* message length */ + - sizeof(gp_command_count) + + sizeof(queryCommandId) + sizeof(sessionUserId) /* sessionUserIsSuper */ + sizeof(outerUserId) /* outerUserIsSuper */ + sizeof(currentUserId) + @@ -963,9 +969,9 @@ buildGpQueryString(DispatchCommandQueryParms *pQueryParms, pos += 4; /* placeholder for message length */ - tmp = htonl(gp_command_count); - memcpy(pos, &tmp, sizeof(gp_command_count)); - pos += sizeof(gp_command_count); + tmp = htonl(queryCommandId); + memcpy(pos, &tmp, sizeof(queryCommandId)); + pos += sizeof(queryCommandId); tmp = htonl(sessionUserId); memcpy(pos, &tmp, sizeof(sessionUserId)); diff --git a/src/backend/cdb/dispatcher/cdbgang.c b/src/backend/cdb/dispatcher/cdbgang.c index e8a53b6464a2..7b4e6775072f 100644 --- a/src/backend/cdb/dispatcher/cdbgang.c +++ b/src/backend/cdb/dispatcher/cdbgang.c @@ -808,6 +808,7 @@ GpResetSessionIfNeeded(void) gp_session_id = newSessionId; gp_command_count = 0; + MyProc->queryCommandId = 0; pgstat_report_sessionid(newSessionId); /* Update the slotid for our singleton reader. */ diff --git a/src/backend/cdb/endpoint/cdbendpointutils.c b/src/backend/cdb/endpoint/cdbendpointutils.c index 4e1907ea6428..b6ebab18263d 100644 --- a/src/backend/cdb/endpoint/cdbendpointutils.c +++ b/src/backend/cdb/endpoint/cdbendpointutils.c @@ -574,14 +574,14 @@ generate_endpoint_name(char *name, const char *cursorName) len += ENDPOINT_NAME_SESSIONID_LEN; /* - * part3: gp_command_count In theory cursor name + gp_session_id is + * part3: MyProc->queryCommandId. In theory cursor name + gp_session_id is * enough, but we'd keep this part to avoid confusion or potential issues * for the scenario that in the same session (thus same gp_session_id), * two endpoints with same cursor names (happens the cursor is * dropped/rollbacked and then recreated) and retrieve the endpoints would * be confusing for users that in the same retrieve connection. */ - snprintf(name + len, ENDPOINT_NAME_COMMANDID_LEN + 1, "%08x", gp_command_count); + snprintf(name + len, ENDPOINT_NAME_COMMANDID_LEN + 1, "%08x", MyProc->queryCommandId); len += ENDPOINT_NAME_COMMANDID_LEN; name[len] = '\0'; diff --git a/src/backend/cdb/motion/ic_proxy_backend.c b/src/backend/cdb/motion/ic_proxy_backend.c index 4dd030b8849b..bfea7613a658 100644 --- a/src/backend/cdb/motion/ic_proxy_backend.c +++ b/src/backend/cdb/motion/ic_proxy_backend.c @@ -34,6 +34,7 @@ #include "cdb/cdbvars.h" #include "cdb/ml_ipc.h" #include "executor/execdesc.h" +#include "storage/proc.h" #include "storage/shmem.h" #include "ic_proxy.h" @@ -444,7 +445,7 @@ ic_proxy_backend_connect(ICProxyBackendContext *context, ChunkTransportStateEntr /* message key for a HELLO message */ ic_proxy_key_init(&backend->key, /* key itself */ gp_session_id, /* sessionId */ - gp_command_count, /* commandId */ + MyProc->queryCommandId, /* commandId */ pEntry->sendSlice->sliceIndex, /* sendSliceIndex */ pEntry->recvSlice->sliceIndex, /* recvSliceIndex */ GpIdentity.segindex, /* localContentId */ diff --git a/src/backend/cdb/motion/ic_udpifc.c b/src/backend/cdb/motion/ic_udpifc.c index f68be0e8b011..a0aed3e761bc 100644 --- a/src/backend/cdb/motion/ic_udpifc.c +++ b/src/backend/cdb/motion/ic_udpifc.c @@ -45,6 +45,7 @@ #include "postmaster/postmaster.h" #include "storage/latch.h" #include "storage/pmsignal.h" +#include "storage/proc.h" #include "utils/builtins.h" #include "utils/guc.h" #include "utils/memutils.h" @@ -3087,7 +3088,7 @@ SetupUDPIFCInterconnect_Internal(SliceTable *sliceTable) } } - addCursorIcEntry(ich_table, sliceTable->ic_instance_id, gp_command_count); + addCursorIcEntry(ich_table, sliceTable->ic_instance_id, MyProc->queryCommandId); /* save the latest transaction id */ rx_control_info.lastDXatId = distTransId; } diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index f5d44d83fb54..ecb3dda8f9c4 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -113,6 +113,10 @@ queryDesc->ddesc->parallelCursorName && \ strlen(queryDesc->ddesc->parallelCursorName) > 0) +#define UPDATE_COMMAND_ID_AT_START(queryDesc, prevCommandId) UpdateCommandId(queryDesc, prevCommandId, __FUNCTION__, true) +#define UPDATE_COMMAND_ID(queryDesc, prevCommandId) UpdateCommandId(queryDesc, prevCommandId, __FUNCTION__, false) +#define RESTORE_COMMAND_ID(queryDesc, prevCommandId) RestoreCommandId(queryDesc, prevCommandId, __FUNCTION__) + /* Hooks for plugins to get control in ExecutorStart/Run/Finish/End */ ExecutorStart_hook_type ExecutorStart_hook = NULL; ExecutorRun_hook_type ExecutorRun_hook = NULL; @@ -183,9 +187,48 @@ static char *ExecBuildSlotValueDescription(Oid reloid, int maxfieldlen); static void EvalPlanQualStart(EPQState *epqstate, Plan *planTree); +static inline void UpdateCommandId(QueryDesc *queryDesc, int *prevCommandId, const char *functionName, bool trackStart); +static inline void RestoreCommandId(QueryDesc *queryDesc, int prevCommandId, const char *functionName); + /* end of local decls */ +static inline void +UpdateCommandId(QueryDesc *queryDesc, int *prevCommandId, const char *functionName, bool trackStart) +{ + if (Gp_role != GP_ROLE_EXECUTE) + { + *prevCommandId = MyProc->queryCommandId; + MyProc->queryCommandId = queryDesc->command_id; + } + +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("track_query_command_id") == FaultInjectorTypeSkip || + (trackStart && SIMPLE_FAULT_INJECTOR("track_query_command_id_at_start") == FaultInjectorTypeSkip)) + elog(NOTICE, + "START %s | Q: %s | QUERY ID: %d", + functionName, + queryDesc->sourceText, + MyProc->queryCommandId); +#endif +} + +static inline void +RestoreCommandId(QueryDesc *queryDesc, int prevCommandId, const char *functionName) +{ +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("track_query_command_id") == FaultInjectorTypeSkip) + elog(NOTICE, + "END %s | Q: %s | QUERY ID: %d", + functionName, + queryDesc->sourceText, + MyProc->queryCommandId); +#endif + + if (Gp_role != GP_ROLE_EXECUTE) + MyProc->queryCommandId = prevCommandId; +} + /* ---------------------------------------------------------------- * ExecutorStart * @@ -216,10 +259,24 @@ static void EvalPlanQualStart(EPQState *epqstate, Plan *planTree); void ExecutorStart(QueryDesc *queryDesc, int eflags) { - if (ExecutorStart_hook) - (*ExecutorStart_hook) (queryDesc, eflags); - else - standard_ExecutorStart(queryDesc, eflags); + int prevCommandId = 0; + UPDATE_COMMAND_ID_AT_START(queryDesc, &prevCommandId); + + PG_TRY(); + { + if (ExecutorStart_hook) + (*ExecutorStart_hook) (queryDesc, eflags); + else + standard_ExecutorStart(queryDesc, eflags); + } + PG_CATCH(); + { + RESTORE_COMMAND_ID(queryDesc, prevCommandId); + PG_RE_THROW(); + } + PG_END_TRY(); + + RESTORE_COMMAND_ID(queryDesc, prevCommandId); } void @@ -784,6 +841,10 @@ ExecutorRun(QueryDesc *queryDesc, * at the definition of the static variable executor_run_nesting_level. */ executor_run_nesting_level++; + + int prevCommandId = 0; + UPDATE_COMMAND_ID(queryDesc, &prevCommandId); + PG_TRY(); { if (ExecutorRun_hook) @@ -795,9 +856,12 @@ ExecutorRun(QueryDesc *queryDesc, PG_CATCH(); { executor_run_nesting_level--; + RESTORE_COMMAND_ID(queryDesc, prevCommandId); PG_RE_THROW(); } PG_END_TRY(); + + RESTORE_COMMAND_ID(queryDesc, prevCommandId); } void @@ -1058,10 +1122,24 @@ standard_ExecutorRun(QueryDesc *queryDesc, void ExecutorFinish(QueryDesc *queryDesc) { - if (ExecutorFinish_hook) - (*ExecutorFinish_hook) (queryDesc); - else - standard_ExecutorFinish(queryDesc); + int prevCommandId = 0; + UPDATE_COMMAND_ID(queryDesc, &prevCommandId); + + PG_TRY(); + { + if (ExecutorFinish_hook) + (*ExecutorFinish_hook) (queryDesc); + else + standard_ExecutorFinish(queryDesc); + } + PG_CATCH(); + { + RESTORE_COMMAND_ID(queryDesc, prevCommandId); + PG_RE_THROW(); + } + PG_END_TRY(); + + RESTORE_COMMAND_ID(queryDesc, prevCommandId); } void @@ -1118,10 +1196,24 @@ standard_ExecutorFinish(QueryDesc *queryDesc) void ExecutorEnd(QueryDesc *queryDesc) { - if (ExecutorEnd_hook) - (*ExecutorEnd_hook) (queryDesc); - else - standard_ExecutorEnd(queryDesc); + int prevCommandId = 0; + UPDATE_COMMAND_ID(queryDesc, &prevCommandId); + + PG_TRY(); + { + if (ExecutorEnd_hook) + (*ExecutorEnd_hook) (queryDesc); + else + standard_ExecutorEnd(queryDesc); + } + PG_CATCH(); + { + RESTORE_COMMAND_ID(queryDesc, prevCommandId); + PG_RE_THROW(); + } + PG_END_TRY(); + + RESTORE_COMMAND_ID(queryDesc, prevCommandId); } void diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index 29010931fa79..9f7180e8d6d3 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -23,6 +23,7 @@ #include "utils/memutils.h" #include "utils/timestamp.h" #include "miscadmin.h" +#include "storage/proc.h" #include "storage/shmem.h" #include "cdb/cdbdtxcontextinfo.h" #include "cdb/cdbtm.h" @@ -456,7 +457,7 @@ pickInstrFromShmem(const Plan *plan, int instrument_options) slot->pid = MyProcPid; gp_gettmid(&(slot->tmid)); slot->ssid = gp_session_id; - slot->ccnt = gp_command_count; + slot->ccnt = MyProc->queryCommandId; slot->nid = (int16) plan->plan_node_id; MemoryContext contextSave = MemoryContextSwitchTo(TopMemoryContext); diff --git a/src/backend/executor/nodeShareInputScan.c b/src/backend/executor/nodeShareInputScan.c index fe2a7bcaead8..b54911e997ec 100644 --- a/src/backend/executor/nodeShareInputScan.c +++ b/src/backend/executor/nodeShareInputScan.c @@ -688,7 +688,7 @@ void shareinput_create_bufname_prefix(char* p, int size, int share_id) { snprintf(p, size, "SIRW_%d_%d_%d", - gp_session_id, gp_command_count, share_id); + gp_session_id, MyProc->queryCommandId, share_id); } /* @@ -814,7 +814,7 @@ get_shareinput_reference(int share_id) LWLockAcquire(ShareInputScanLock, LW_EXCLUSIVE); tag.session_id = gp_session_id; - tag.command_count = gp_command_count; + tag.command_count = MyProc->queryCommandId; tag.share_id = share_id; xslice_state = hash_search(shareinput_Xslice_hash, &tag, diff --git a/src/backend/gpopt/utils/COptTasks.cpp b/src/backend/gpopt/utils/COptTasks.cpp index d82b8a70477c..541389be2951 100644 --- a/src/backend/gpopt/utils/COptTasks.cpp +++ b/src/backend/gpopt/utils/COptTasks.cpp @@ -19,6 +19,7 @@ extern "C" { #include "cdb/cdbvars.h" #include "optimizer/hints.h" #include "optimizer/orca.h" +#include "storage/proc.h" #include "utils/fmgroids.h" #include "utils/guc.h" } @@ -848,7 +849,7 @@ COptTasks::OptimizeTask(void *ptr) plan_dxl = COptimizer::PdxlnOptimize( mp, &mda, query_dxl, query_output_dxlnode_array, cte_dxlnode_array, expr_evaluator, num_segments, gp_session_id, - gp_command_count, search_strategy_arr, optimizer_config); + MyProc->queryCommandId, search_strategy_arr, optimizer_config); if (opt_ctxt->m_should_serialize_plan_dxl) { diff --git a/src/backend/postmaster/backoff.c b/src/backend/postmaster/backoff.c index b8e40c7c0cba..882ff1f45543 100644 --- a/src/backend/postmaster/backoff.c +++ b/src/backend/postmaster/backoff.c @@ -612,7 +612,7 @@ BackoffBackendTickExpired(void) { BackoffBackendLocalEntry *le; BackoffBackendSharedEntry *se; - StatementId currentStatementId = {gp_session_id, gp_command_count}; + StatementId currentStatementId = {gp_session_id, MyProc != NULL ? MyProc->queryCommandId : 0}; backoffTickCounter = 0; diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 451e3b110e57..b8ab7089a252 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -576,7 +576,7 @@ InitProcess(void) /* Set wait portal (do not check if resource scheduling is enabled) */ MyProc->waitPortalId = INVALID_PORTALID; - MyProc->queryCommandId = -1; + MyProc->queryCommandId = 0; /* Init gxact */ MyTmGxact->gxid = InvalidDistributedTransactionId; @@ -748,7 +748,7 @@ InitAuxiliaryProcess(void) */ PGSemaphoreReset(MyProc->sem); - MyProc->queryCommandId = -1; + MyProc->queryCommandId = 0; /* * Arrange to clean up at process exit. diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index e412672f4285..beb70b721301 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -5194,7 +5194,10 @@ PostgresMain(int argc, char *argv[], /* Reset elog globals */ currentSliceId = UNSET_SLICE_ID; if (Gp_role == GP_ROLE_EXECUTE) - gp_command_count = 0; + { + gp_command_count = 0; + MyProc->queryCommandId = 0; + } /* * Do deactiving and runaway detecting before ReadyForQuery(), @@ -5477,8 +5480,12 @@ PostgresMain(int argc, char *argv[], /* Set statement_timestamp() */ SetCurrentStatementStartTimestamp(); - /* get the client command serial# */ - gp_command_count = pq_getmsgint(&input_message, 4); + /* + * Get the command id from the QD. gp_command_count on QE + * is set to be the same as queryCommandId. + */ + MyProc->queryCommandId = pq_getmsgint(&input_message, 4); + gp_command_count = MyProc->queryCommandId; elog(DEBUG1, "Message type %c received by from libpq, len = %d", firstchar, input_message.len); /* TODO: Remove this */ diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 251860682ec4..dbeff8c054e2 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -25,6 +25,7 @@ #include "executor/tstoreReceiver.h" #include "miscadmin.h" #include "pg_trace.h" +#include "storage/proc.h" #include "tcop/pquery.h" #include "tcop/utility.h" #include "utils/memutils.h" @@ -124,9 +125,15 @@ CreateQueryDesc(PlannedStmt *plannedstmt, /* not yet executed */ qd->already_executed = false; + int prevCommandId = MyProc->queryCommandId; + if (Gp_role != GP_ROLE_EXECUTE) increment_command_count(); + qd->command_id = MyProc->queryCommandId; + + MyProc->queryCommandId = prevCommandId; + return qd; } @@ -295,9 +302,23 @@ ProcessQuery(Portal portal, if (Gp_role == GP_ROLE_DISPATCH) { - /* MPP-4082. Issue automatic ANALYZE if conditions are satisfied. */ - bool inFunction = false; - auto_stats(cmdType, relationOid, queryDesc->es_processed, inFunction); + int prevCommandId = MyProc->queryCommandId; + MyProc->queryCommandId = queryDesc->command_id; + + PG_TRY(); + { + /* MPP-4082. Issue automatic ANALYZE if conditions are satisfied. */ + bool inFunction = false; + auto_stats(cmdType, relationOid, queryDesc->es_processed, inFunction); + } + PG_CATCH(); + { + MyProc->queryCommandId = prevCommandId; + PG_RE_THROW(); + } + PG_END_TRY(); + + MyProc->queryCommandId = prevCommandId; } FreeQueryDesc(queryDesc); @@ -2016,7 +2037,7 @@ PortalBackoffEntryInit(Portal portal) gp_session_id > -1) { /* Initialize the SHM backend entry */ - BackoffBackendEntryInit(gp_session_id, gp_command_count, portal->queueId); + BackoffBackendEntryInit(gp_session_id, MyProc != NULL ? MyProc->queryCommandId : 0, portal->queueId); } } diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 8a3157373929..dd79899ac69f 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -383,6 +383,19 @@ ProcessUtility(PlannedStmt *pstmt, Assert(pstmt->commandType == CMD_UTILITY); Assert(queryString != NULL); /* required as of 8.4 */ + int prevCommandId = MyProc->queryCommandId; + + if (Gp_role != GP_ROLE_EXECUTE) + increment_command_count(); + +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("track_query_command_id") == FaultInjectorTypeSkip || + SIMPLE_FAULT_INJECTOR("track_query_command_id_at_start") == FaultInjectorTypeSkip) + elog(NOTICE, "START %s | Q: %s | QUERY ID: %d", + __FUNCTION__, + queryString, + MyProc->queryCommandId); +#endif /* * Greenplum specific code: * Please refer to the comments at the definition of process_utility_nesting_level. @@ -407,10 +420,33 @@ ProcessUtility(PlannedStmt *pstmt, } PG_CATCH(); { +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("track_query_command_id") == FaultInjectorTypeSkip) + elog(NOTICE, "END %s | Q: %s | QUERY ID: %d", + __FUNCTION__, + queryString, + MyProc->queryCommandId); +#endif + /* restore queryCommandId, which was updated in increment_command_count() */ + if (Gp_role != GP_ROLE_EXECUTE) + MyProc->queryCommandId = prevCommandId; + process_utility_nesting_level--; PG_RE_THROW(); } PG_END_TRY(); + +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("track_query_command_id") == FaultInjectorTypeSkip) + elog(NOTICE, "END %s | Q: %s | QUERY ID: %d", + __FUNCTION__, + queryString, + MyProc->queryCommandId); +#endif + + /* restore queryCommandId, which was updated in increment_command_count() */ + if (Gp_role != GP_ROLE_EXECUTE) + MyProc->queryCommandId = prevCommandId; } /* diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 1f3a52e33806..d7111005d497 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -3022,8 +3022,8 @@ log_line_prefix(StringInfo buf, ErrorData *edata) int j = buf->len; if (gp_session_id > 0) appendStringInfo(buf, "con%d ", gp_session_id); - if (gp_command_count > 0) - appendStringInfo(buf, "cmd%d ", gp_command_count); + if (MyProc != NULL && MyProc->queryCommandId > 0) + appendStringInfo(buf, "cmd%d ", MyProc->queryCommandId); if (Gp_role == GP_ROLE_EXECUTE) appendStringInfo(buf, "seg%d ", GpIdentity.segindex); if (currentSliceId > 0) @@ -3769,7 +3769,7 @@ write_syslogger_in_csv(ErrorData *edata, bool amsyslogger) /* GPDB specific options */ syslogger_write_int32(true, "con", gp_session_id, amsyslogger, true); - syslogger_write_int32(true, "cmd", gp_command_count, amsyslogger, true); + syslogger_write_int32(true, "cmd", MyProc != NULL ? MyProc->queryCommandId : 0, amsyslogger, true); syslogger_write_int32(false, "seg", GpIdentity.segindex, amsyslogger, true); syslogger_write_int32(true, "slice", currentSliceId, amsyslogger, true); { @@ -3908,7 +3908,7 @@ write_message_to_server_log(int elevel, fix_fields.omit_location = omit_location ? 't' : 'f'; fix_fields.gp_is_primary = 't'; fix_fields.gp_session_id = gp_session_id; - fix_fields.gp_command_count = gp_command_count; + fix_fields.gp_command_count = MyProc != NULL ? MyProc->queryCommandId : 0; fix_fields.gp_segment_id = GpIdentity.segindex; fix_fields.slice_id = currentSliceId; fix_fields.error_cursor_pos = cursorpos; @@ -5020,7 +5020,7 @@ StandardHandlerForSigillSigsegvSigbus_OnMainThread(char *processName, SIGNAL_ARG } errorData->gp_session_id = gp_session_id; - errorData->gp_command_count = gp_command_count; + errorData->gp_command_count = MyProc != NULL ? MyProc->queryCommandId : 0; errorData->gp_segment_id = GpIdentity.segindex; errorData->slice_id = currentSliceId; errorData->signal_num = (int32)postgres_signal_arg; diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index b7de35d016fc..f6fcadd73284 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -34,6 +34,7 @@ #include "utils/guc.h" #include "cdb/cdbvars.h" /* Gp_role, GpIdentity.segindex, currentSliceId */ +#include "storage/proc.h" extern char **environ; extern int PostPortNumber; /* GPDB: Helps identify child processes */ @@ -380,8 +381,8 @@ set_ps_display(const char *activity, bool force) } /* Add count of commands received from client session. */ - if (gp_command_count > 0 && ep - cp > 0) - cp += snprintf(cp, ep - cp, "cmd%d ", gp_command_count); + if (MyProc != NULL && MyProc->queryCommandId > 0 && ep - cp > 0) + cp += snprintf(cp, ep - cp, "cmd%d ", MyProc->queryCommandId); /* Add slice number information */ if (currentSliceId > 0 && ep - cp > 0) diff --git a/src/backend/utils/misc/test/ps_status_test.c b/src/backend/utils/misc/test/ps_status_test.c index c877cbf085c9..8857c03fdc39 100644 --- a/src/backend/utils/misc/test/ps_status_test.c +++ b/src/backend/utils/misc/test/ps_status_test.c @@ -21,7 +21,6 @@ test__set_ps_display(void **state) gp_session_id = 1024; Gp_role = GP_ROLE_DISPATCH; GpIdentity.segindex = 24; - gp_command_count = 1024; currentSliceId = 40; set_ps_display("testing activity", true); @@ -50,7 +49,6 @@ test__set_ps_display__real_act_prefix_size_overflow(void **state) gp_session_id = 26351; Gp_role = GP_ROLE_DISPATCH; GpIdentity.segindex = -1; - gp_command_count = 964; currentSliceId = -1; set_ps_display("testing activity", true); @@ -82,7 +80,6 @@ test__set_ps_display__real_act_prefix_size(void **state) gp_session_id = 26351; Gp_role = GP_ROLE_DISPATCH; GpIdentity.segindex = -1; - gp_command_count = 964; currentSliceId = -1; set_ps_display(activity, true); diff --git a/src/backend/utils/workfile_manager/workfile_mgr.c b/src/backend/utils/workfile_manager/workfile_mgr.c index bfab50e4e050..995b264fb155 100644 --- a/src/backend/utils/workfile_manager/workfile_mgr.c +++ b/src/backend/utils/workfile_manager/workfile_mgr.c @@ -83,6 +83,7 @@ #include "storage/fd.h" #include "storage/ipc.h" #include "storage/lwlock.h" +#include "storage/proc.h" #include "storage/shmem.h" #include "utils/builtins.h" #include "utils/faultinjector.h" @@ -599,7 +600,7 @@ workfile_mgr_create_set_internal(const char *operator_name, const char *prefix) * Find our per-query entry (or allocate, on first use) */ key.session_id = gp_session_id; - key.command_count = gp_command_count; + key.command_count = MyProc->queryCommandId; perquery = (WorkFileUsagePerQuery *) hash_search(workfile_shared->per_query_hash, &key, HASH_ENTER_NULL, &found); @@ -632,7 +633,7 @@ workfile_mgr_create_set_internal(const char *operator_name, const char *prefix) workfile_shared->num_active++; work_set->session_id = gp_session_id; - work_set->command_count = gp_command_count; + work_set->command_count = MyProc->queryCommandId; work_set->slice_id = currentSliceId; work_set->perquery = perquery; work_set->num_files = 0; diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h index b5039438808a..9ba5a01be40c 100644 --- a/src/include/executor/execdesc.h +++ b/src/include/executor/execdesc.h @@ -289,6 +289,7 @@ typedef struct QueryDesc CmdType operation; /* CMD_SELECT, CMD_UPDATE, etc. */ PlannedStmt *plannedstmt; /* planner's output (could be utility, too) */ const char *sourceText; /* source text of the query */ + int command_id; /* id of the query */ Snapshot snapshot; /* snapshot to use for query */ Snapshot crosscheck_snapshot; /* crosscheck for RI update/delete */ DestReceiver *dest; /* the destination for tuple output */ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 47cdff6e2c01..37a77e3bf456 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -209,8 +209,7 @@ struct PGPROC /* * Current command_id for the running query - * This counter is not dead code although there is no consumer in the gpdb - * code tree, it is required by external monitoring infrastructure. + * This counter can be used by external monitoring infrastructure. * As a monitoring approach, each query execution is assigned with a unique * ID. The queryCommandId is part of the ID. Monitoring extension with * shared memory access can use queryCommandId to map query execution with diff --git a/src/include/utils/session_state.h b/src/include/utils/session_state.h index 08d0835856b1..48cd9cc02119 100644 --- a/src/include/utils/session_state.h +++ b/src/include/utils/session_state.h @@ -96,7 +96,7 @@ typedef struct SessionState */ void *resGroupSlot; - /* gp_command_count of the latest cursor command in this session */ + /* MyProc->queryCommandId of the latest cursor command in this session */ int latestCursorCommandId; #ifdef USE_ASSERT_CHECKING diff --git a/src/test/regress/expected/gp_query_id.out b/src/test/regress/expected/gp_query_id.out new file mode 100644 index 000000000000..2d699b623188 --- /dev/null +++ b/src/test/regress/expected/gp_query_id.out @@ -0,0 +1,863 @@ +-- +-- Test the query command identification +-- +set client_min_messages = notice; +select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +create or replace function sirv_function() returns int as $$ +declare + result int; +begin + create table test_data (x int, y int) with (appendonly=true) distributed by (x); + insert into test_data values (1, 1); + select count(1) into result from test_data; + drop table test_data; + return result; +end $$ language plpgsql; +\c +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: END ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 5 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 5 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 8 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 8 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: select sirv_function(); | QUERY ID: 4 + sirv_function +--------------- + 1 +(1 row) + +-- Test that the query command id is correct after execution of queries in the InitPlan +create table t as select (select sirv_function()) as res distributed by (res); +NOTICE: START ProcessUtility | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 10 +NOTICE: START ExecutorStart | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 12 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 12 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 15 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 15 +NOTICE: END ExecutorStart | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorRun | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorRun | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorFinish | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorFinish | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorEnd | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorEnd | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ProcessUtility | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 10 +-- Test a simple query +select * from t; +NOTICE: START ExecutorStart | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorStart | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorRun | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorRun | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorFinish | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorFinish | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorEnd | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorEnd | Q: select * from t; | QUERY ID: 17 + res +----- + 1 +(1 row) + +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 19 +NOTICE: END ProcessUtility | Q: drop table t; | QUERY ID: 19 +-- Test a cursor +begin; +NOTICE: START ProcessUtility | Q: begin; | QUERY ID: 21 +NOTICE: END ProcessUtility | Q: begin; | QUERY ID: 21 +declare cur1 cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 23 +NOTICE: START ExecutorStart | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorStart | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 23 +fetch 1 from cur1; +NOTICE: START ProcessUtility | Q: fetch 1 from cur1; | QUERY ID: 26 +NOTICE: START ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 27 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 27 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 30 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 30 +NOTICE: END ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: fetch 1 from cur1; | QUERY ID: 26 + res +----- + 1 +(1 row) + +fetch all from cur1; +NOTICE: START ProcessUtility | Q: fetch all from cur1; | QUERY ID: 32 +NOTICE: START ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: fetch all from cur1; | QUERY ID: 32 + res +----- +(0 rows) + +commit; +NOTICE: START ProcessUtility | Q: commit; | QUERY ID: 34 +NOTICE: END ProcessUtility | Q: commit; | QUERY ID: 34 +NOTICE: START ExecutorFinish | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorFinish | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: START ExecutorEnd | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorEnd | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +-- Test two cursors +begin; +NOTICE: START ProcessUtility | Q: begin; | QUERY ID: 36 +NOTICE: END ProcessUtility | Q: begin; | QUERY ID: 36 +declare cur1_a cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 38 +NOTICE: START ExecutorStart | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorStart | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 38 +fetch 1 from cur1_a; +NOTICE: START ProcessUtility | Q: fetch 1 from cur1_a; | QUERY ID: 41 +NOTICE: START ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 42 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 42 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 45 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 45 +NOTICE: END ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: fetch 1 from cur1_a; | QUERY ID: 41 + res +----- + 1 +(1 row) + +declare cur2_b cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 47 +NOTICE: START ExecutorStart | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorStart | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 47 +fetch 2 from cur2_b; +NOTICE: START ProcessUtility | Q: fetch 2 from cur2_b; | QUERY ID: 50 +NOTICE: START ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 51 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 51 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 54 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 54 +NOTICE: END ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: fetch 2 from cur2_b; | QUERY ID: 50 + res +----- + 1 +(1 row) + +fetch all from cur2_b; +NOTICE: START ProcessUtility | Q: fetch all from cur2_b; | QUERY ID: 56 +NOTICE: START ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: fetch all from cur2_b; | QUERY ID: 56 + res +----- +(0 rows) + +fetch all from cur1_a; +NOTICE: START ProcessUtility | Q: fetch all from cur1_a; | QUERY ID: 58 +NOTICE: START ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: fetch all from cur1_a; | QUERY ID: 58 + res +----- +(0 rows) + +commit; +NOTICE: START ProcessUtility | Q: commit; | QUERY ID: 60 +NOTICE: END ProcessUtility | Q: commit; | QUERY ID: 60 +NOTICE: START ExecutorFinish | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorFinish | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ExecutorEnd | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorEnd | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ExecutorFinish | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorFinish | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: START ExecutorEnd | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorEnd | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +-- Test partitioned tables +create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); +NOTICE: START ProcessUtility | Q: create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); | QUERY ID: 62 +NOTICE: END ProcessUtility | Q: create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); | QUERY ID: 62 +alter table t rename to t1; +NOTICE: START ProcessUtility | Q: alter table t rename to t1; | QUERY ID: 64 +NOTICE: END ProcessUtility | Q: alter table t rename to t1; | QUERY ID: 64 +drop table t1; +NOTICE: START ProcessUtility | Q: drop table t1; | QUERY ID: 66 +NOTICE: END ProcessUtility | Q: drop table t1; | QUERY ID: 66 +-- Test a function written in sql language, that optimizers cannot inline +create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; +NOTICE: START ProcessUtility | Q: create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; | QUERY ID: 68 +NOTICE: END ProcessUtility | Q: create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; | QUERY ID: 68 +select not_inlineable_sql_func(i) from generate_series(1, 10)i; +NOTICE: START ExecutorStart | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorStart | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorRun | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorRun | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorFinish | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorFinish | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorEnd | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorEnd | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 + not_inlineable_sql_func +------------------------- + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 1 +(10 rows) + +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 +NOTICE: END ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 +NOTICE: START ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +-- Test the query command ids dispatched to segments +-- start_matchsubs +-- m/select pg_catalog.pg_relation_size\(.*\)/ +-- s/select pg_catalog.pg_relation_size\(.*\)/select pg_catalog.pg_relation_size\(\)/ +-- m/select pg_catalog.gp_acquire_sample_rows\(.*\)/ +-- s/select pg_catalog.gp_acquire_sample_rows\(.*\)/select pg_catalog.gp_acquire_sample_rows\(\)/ +-- m/select pg_catalog.gp_acquire_correlations\(.*\)/ +-- s/select pg_catalog.gp_acquire_correlations\(.*\)/select pg_catalog.gp_acquire_correlations\(\)/ +-- end_matchsubs +select gp_inject_fault_infinite('track_query_command_id_at_start', 'skip', dbid) from gp_segment_configuration; + gp_inject_fault_infinite +-------------------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +create table t as select 1; +NOTICE: START ProcessUtility | Q: create table t as select 1; | QUERY ID: 86 +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named '?column?' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg0 slice1 127.0.1.1:7002 pid=1429677) +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg2 127.0.1.1:7004 pid=1429664) +create table t (i int, j text) with (appendonly = true) distributed by (i); +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg2 127.0.1.1:7004 pid=1429664) +insert into t select i, (i + 1)::text from generate_series(1, 100) i; +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg0 slice1 127.0.1.1:7002 pid=1429679) +vacuum analyze t; +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(24939, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(24939, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(24939, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(24939, 10000, 'f'); | QUERY ID: 96 +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(24939, 10000, 'f'); | QUERY ID: 96 (seg0 slice1 127.0.1.1:7002 pid=1429663) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(24939, 10000, 'f'); | QUERY ID: 96 (seg1 slice1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(24939, 10000, 'f'); | QUERY ID: 96 (seg2 slice1 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(24939, 'f'); | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(24939, 'f'); | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1429664) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(24939, 'f'); | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1429663) +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg0 127.0.1.1:7002 pid=1429663) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg1 127.0.1.1:7003 pid=1429662) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg2 127.0.1.1:7004 pid=1429664) +select gp_inject_fault_infinite('track_query_command_id_at_start', 'reset', dbid) from gp_segment_configuration; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id_at_start', 'reset', dbid) from gp_segment_configuration; | QUERY ID: 100 + gp_inject_fault_infinite +-------------------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +-- Test the query command id after an error has happened +select gp_inject_fault('appendonly_insert', 'panic', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; +WARNING: consider disabling FTS probes while injecting a panic. +HINT: Inject an infinite 'skip' into the 'fts_probe' fault to disable FTS probing. + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: +(4 rows) + +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: END ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +-- First query will fail with an error due to insert inside the function +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 107 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 107 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 106 +ERROR: fault triggered, fault name:'appendonly_insert' fault type:'panic' (seg1 127.0.1.1:7003 pid=1429662) +CONTEXT: SQL statement "insert into test_data values (1, 1)" +PL/pgSQL function sirv_function() line 6 at SQL statement +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 3 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 3 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 6 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 6 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorFinish | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorFinish | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorEnd | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorEnd | Q: select sirv_function(); | QUERY ID: 2 + sirv_function +--------------- + 1 +(1 row) + +select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; +NOTICE: START ExecutorStart | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorStart | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorRun | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorRun | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: +(4 rows) + +-- Test an exception caught inside the function +\c +create table t (i int); +NOTICE: START ProcessUtility | Q: create table t (i int); | QUERY ID: 2 +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +NOTICE: END ProcessUtility | Q: create table t (i int); | QUERY ID: 2 +insert into t values(0); +NOTICE: START ExecutorStart | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorRun | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: insert into t values(0); | QUERY ID: 4 +do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; +NOTICE: START ProcessUtility | Q: do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; | QUERY ID: 6 +NOTICE: START ExecutorStart | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: END ExecutorStart | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: START ExecutorRun | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: END ExecutorRun | Q: select 1 / i from t | QUERY ID: 7 +WARNING: division by zero (seg1 slice1 127.0.1.1:7003 pid=1429847) +WARNING: 2 +WARNING: 3 +NOTICE: END ProcessUtility | Q: do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; | QUERY ID: 6 +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 +NOTICE: END ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 +NOTICE: START ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +drop function sirv_function(); +drop function not_inlineable_sql_func(i int); +reset client_min_messages; diff --git a/src/test/regress/expected/gp_query_id_optimizer.out b/src/test/regress/expected/gp_query_id_optimizer.out new file mode 100644 index 000000000000..328abede47ff --- /dev/null +++ b/src/test/regress/expected/gp_query_id_optimizer.out @@ -0,0 +1,863 @@ +-- +-- Test the query command identification +-- +set client_min_messages = notice; +select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +create or replace function sirv_function() returns int as $$ +declare + result int; +begin + create table test_data (x int, y int) with (appendonly=true) distributed by (x); + insert into test_data values (1, 1); + select count(1) into result from test_data; + drop table test_data; + return result; +end $$ language plpgsql; +\c +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: END ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 2 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 5 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 5 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 6 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 7 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 8 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 8 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: select sirv_function(); | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: select sirv_function(); | QUERY ID: 4 + sirv_function +--------------- + 1 +(1 row) + +-- Test that the query command id is correct after execution of queries in the InitPlan +create table t as select (select sirv_function()) as res distributed by (res); +NOTICE: START ProcessUtility | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 10 +NOTICE: START ExecutorStart | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 12 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 12 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 13 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 14 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 15 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 15 +NOTICE: END ExecutorStart | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorRun | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorRun | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorFinish | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorFinish | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: START ExecutorEnd | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ExecutorEnd | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 11 +NOTICE: END ProcessUtility | Q: create table t as select (select sirv_function()) as res distributed by (res); | QUERY ID: 10 +-- Test a simple query +select * from t; +NOTICE: START ExecutorStart | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorStart | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorRun | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorRun | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorFinish | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorFinish | Q: select * from t; | QUERY ID: 17 +NOTICE: START ExecutorEnd | Q: select * from t; | QUERY ID: 17 +NOTICE: END ExecutorEnd | Q: select * from t; | QUERY ID: 17 + res +----- + 1 +(1 row) + +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 19 +NOTICE: END ProcessUtility | Q: drop table t; | QUERY ID: 19 +-- Test a cursor +begin; +NOTICE: START ProcessUtility | Q: begin; | QUERY ID: 21 +NOTICE: END ProcessUtility | Q: begin; | QUERY ID: 21 +declare cur1 cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 23 +NOTICE: START ExecutorStart | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorStart | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 23 +fetch 1 from cur1; +NOTICE: START ProcessUtility | Q: fetch 1 from cur1; | QUERY ID: 26 +NOTICE: START ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 27 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 27 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 28 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 29 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 30 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 30 +NOTICE: END ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: fetch 1 from cur1; | QUERY ID: 26 + res +----- + 1 +(1 row) + +fetch all from cur1; +NOTICE: START ProcessUtility | Q: fetch all from cur1; | QUERY ID: 32 +NOTICE: START ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorRun | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ProcessUtility | Q: fetch all from cur1; | QUERY ID: 32 + res +----- +(0 rows) + +commit; +NOTICE: START ProcessUtility | Q: commit; | QUERY ID: 34 +NOTICE: END ProcessUtility | Q: commit; | QUERY ID: 34 +NOTICE: START ExecutorFinish | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorFinish | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: START ExecutorEnd | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +NOTICE: END ExecutorEnd | Q: declare cur1 cursor for select sirv_function() as res; | QUERY ID: 24 +-- Test two cursors +begin; +NOTICE: START ProcessUtility | Q: begin; | QUERY ID: 36 +NOTICE: END ProcessUtility | Q: begin; | QUERY ID: 36 +declare cur1_a cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 38 +NOTICE: START ExecutorStart | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorStart | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 38 +fetch 1 from cur1_a; +NOTICE: START ProcessUtility | Q: fetch 1 from cur1_a; | QUERY ID: 41 +NOTICE: START ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 42 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 42 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 43 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 44 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 45 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 45 +NOTICE: END ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: fetch 1 from cur1_a; | QUERY ID: 41 + res +----- + 1 +(1 row) + +declare cur2_b cursor for select sirv_function() as res; +NOTICE: START ProcessUtility | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 47 +NOTICE: START ExecutorStart | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorStart | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 47 +fetch 2 from cur2_b; +NOTICE: START ProcessUtility | Q: fetch 2 from cur2_b; | QUERY ID: 50 +NOTICE: START ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 51 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 51 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 52 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 53 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 54 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 54 +NOTICE: END ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: fetch 2 from cur2_b; | QUERY ID: 50 + res +----- + 1 +(1 row) + +fetch all from cur2_b; +NOTICE: START ProcessUtility | Q: fetch all from cur2_b; | QUERY ID: 56 +NOTICE: START ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorRun | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ProcessUtility | Q: fetch all from cur2_b; | QUERY ID: 56 + res +----- +(0 rows) + +fetch all from cur1_a; +NOTICE: START ProcessUtility | Q: fetch all from cur1_a; | QUERY ID: 58 +NOTICE: START ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorRun | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ProcessUtility | Q: fetch all from cur1_a; | QUERY ID: 58 + res +----- +(0 rows) + +commit; +NOTICE: START ProcessUtility | Q: commit; | QUERY ID: 60 +NOTICE: END ProcessUtility | Q: commit; | QUERY ID: 60 +NOTICE: START ExecutorFinish | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorFinish | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ExecutorEnd | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: END ExecutorEnd | Q: declare cur2_b cursor for select sirv_function() as res; | QUERY ID: 48 +NOTICE: START ExecutorFinish | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorFinish | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: START ExecutorEnd | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +NOTICE: END ExecutorEnd | Q: declare cur1_a cursor for select sirv_function() as res; | QUERY ID: 39 +-- Test partitioned tables +create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); +NOTICE: START ProcessUtility | Q: create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); | QUERY ID: 62 +NOTICE: END ProcessUtility | Q: create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); | QUERY ID: 62 +alter table t rename to t1; +NOTICE: START ProcessUtility | Q: alter table t rename to t1; | QUERY ID: 64 +NOTICE: END ProcessUtility | Q: alter table t rename to t1; | QUERY ID: 64 +drop table t1; +NOTICE: START ProcessUtility | Q: drop table t1; | QUERY ID: 66 +NOTICE: END ProcessUtility | Q: drop table t1; | QUERY ID: 66 +-- Test a function written in sql language, that optimizers cannot inline +create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; +NOTICE: START ProcessUtility | Q: create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; | QUERY ID: 68 +NOTICE: END ProcessUtility | Q: create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; | QUERY ID: 68 +select not_inlineable_sql_func(i) from generate_series(1, 10)i; +NOTICE: START ExecutorStart | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorStart | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorRun | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 71 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 72 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 73 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 74 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 75 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 76 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 77 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 78 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 79 +NOTICE: START ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorStart | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorRun | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorFinish | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: START ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorEnd | Q: +select case when i > 5 then 1 else 0 end; + | QUERY ID: 80 +NOTICE: END ExecutorRun | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorFinish | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorFinish | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: START ExecutorEnd | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 +NOTICE: END ExecutorEnd | Q: select not_inlineable_sql_func(i) from generate_series(1, 10)i; | QUERY ID: 70 + not_inlineable_sql_func +------------------------- + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 1 +(10 rows) + +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 +NOTICE: END ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 +NOTICE: START ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 82 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +-- Test the query command ids dispatched to segments +-- start_matchsubs +-- m/select pg_catalog.pg_relation_size\(.*\)/ +-- s/select pg_catalog.pg_relation_size\(.*\)/select pg_catalog.pg_relation_size\(\)/ +-- m/select pg_catalog.gp_acquire_sample_rows\(.*\)/ +-- s/select pg_catalog.gp_acquire_sample_rows\(.*\)/select pg_catalog.gp_acquire_sample_rows\(\)/ +-- m/select pg_catalog.gp_acquire_correlations\(.*\)/ +-- s/select pg_catalog.gp_acquire_correlations\(.*\)/select pg_catalog.gp_acquire_correlations\(\)/ +-- end_matchsubs +select gp_inject_fault_infinite('track_query_command_id_at_start', 'skip', dbid) from gp_segment_configuration; + gp_inject_fault_infinite +-------------------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +create table t as select 1; +NOTICE: START ProcessUtility | Q: create table t as select 1; | QUERY ID: 86 +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause. Creating a NULL policy entry. +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_highest_oid() | QUERY ID: 87 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg0 slice1 127.0.1.1:7002 pid=1445897) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg1 slice1 127.0.1.1:7003 pid=1445898) +NOTICE: START ExecutorStart | Q: create table t as select 1; | QUERY ID: 87 (seg2 slice1 127.0.1.1:7004 pid=1445899) +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 89 (seg2 127.0.1.1:7004 pid=1445884) +create table t (i int, j text) with (appendonly = true) distributed by (i); +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: create table t (i int, j text) with (appendonly = true) distributed by (i); | QUERY ID: 91 (seg0 127.0.1.1:7002 pid=1445882) +insert into t select i, (i + 1)::text from generate_series(1, 100) i; +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ExecutorStart | Q: insert into t select i, (i + 1)::text from generate_series(1, 100) i; | QUERY ID: 93 (seg2 127.0.1.1:7004 pid=1445884) +vacuum analyze t; +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ProcessUtility | Q: vacuum analyze t; | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(180587, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(180587, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ExecutorStart | Q: select pg_catalog.pg_relation_size(180587, /* include_ao_aux */ false, /* physical_ao_size */ false) | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(180587, 10000, 'f'); | QUERY ID: 96 +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(180587, 10000, 'f'); | QUERY ID: 96 (seg0 slice1 127.0.1.1:7002 pid=1445882) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(180587, 10000, 'f'); | QUERY ID: 96 (seg1 slice1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_sample_rows(180587, 10000, 'f'); | QUERY ID: 96 (seg2 slice1 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(180587, 'f'); | QUERY ID: 95 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(180587, 'f'); | QUERY ID: 95 (seg2 127.0.1.1:7004 pid=1445884) +NOTICE: START ExecutorStart | Q: select pg_catalog.gp_acquire_correlations(180587, 'f'); | QUERY ID: 95 (seg0 127.0.1.1:7002 pid=1445882) +drop table t; +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg0 127.0.1.1:7002 pid=1445882) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg1 127.0.1.1:7003 pid=1445883) +NOTICE: START ProcessUtility | Q: drop table t; | QUERY ID: 98 (seg2 127.0.1.1:7004 pid=1445884) +select gp_inject_fault_infinite('track_query_command_id_at_start', 'reset', dbid) from gp_segment_configuration; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id_at_start', 'reset', dbid) from gp_segment_configuration; | QUERY ID: 100 + gp_inject_fault_infinite +-------------------------- + Success: + Success: + Success: + Success: + Success: + Success: + Success: + Success: +(8 rows) + +-- Test the query command id after an error has happened +select gp_inject_fault('appendonly_insert', 'panic', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; +WARNING: consider disabling FTS probes while injecting a panic. +HINT: Inject an infinite 'skip' into the 'fts_probe' fault to disable FTS probing. + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: +(4 rows) + +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: END ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 104 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +-- First query will fail with an error due to insert inside the function +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 106 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 107 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 107 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 108 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 106 +ERROR: fault triggered, fault name:'appendonly_insert' fault type:'panic' (seg1 127.0.1.1:7003 pid=1445883) +CONTEXT: SQL statement "insert into test_data values (1, 1)" +PL/pgSQL function sirv_function() line 6 at SQL statement +select sirv_function(); +NOTICE: START ExecutorStart | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorStart | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorRun | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 3 +NOTICE: END ProcessUtility | Q: create table test_data (x int, y int) with (appendonly=true) distributed by (x) | QUERY ID: 3 +NOTICE: START ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorRun | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: insert into test_data values (1, 1) | QUERY ID: 4 +NOTICE: START ExecutorStart | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorStart | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorRun | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorRun | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorFinish | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: END ExecutorEnd | Q: select count(1) from test_data | QUERY ID: 5 +NOTICE: START ProcessUtility | Q: drop table test_data | QUERY ID: 6 +NOTICE: END ProcessUtility | Q: drop table test_data | QUERY ID: 6 +NOTICE: END ExecutorRun | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorFinish | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorFinish | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: START ExecutorEnd | Q: select sirv_function(); | QUERY ID: 2 +NOTICE: END ExecutorEnd | Q: select sirv_function(); | QUERY ID: 2 + sirv_function +--------------- + 1 +(1 row) + +select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; +NOTICE: START ExecutorStart | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorStart | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorRun | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorRun | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorFinish | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorFinish | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: START ExecutorEnd | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 +NOTICE: END ExecutorEnd | Q: select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; | QUERY ID: 8 + gp_inject_fault +----------------- + Success: + Success: + Success: + Success: +(4 rows) + +-- Test an exception caught inside the function +\c +create table t (i int); +NOTICE: START ProcessUtility | Q: create table t (i int); | QUERY ID: 2 +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +NOTICE: END ProcessUtility | Q: create table t (i int); | QUERY ID: 2 +insert into t values(0); +NOTICE: START ExecutorStart | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorStart | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorRun | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorRun | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorFinish | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorFinish | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: START ExecutorEnd | Q: insert into t values(0); | QUERY ID: 4 +NOTICE: END ExecutorEnd | Q: insert into t values(0); | QUERY ID: 4 +do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; +NOTICE: START ProcessUtility | Q: do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; | QUERY ID: 6 +NOTICE: START ExecutorStart | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: END ExecutorStart | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: START ExecutorRun | Q: select 1 / i from t | QUERY ID: 7 +NOTICE: END ExecutorRun | Q: select 1 / i from t | QUERY ID: 7 +WARNING: division by zero (seg1 slice1 127.0.1.1:7003 pid=1446046) +WARNING: 2 +WARNING: 3 +NOTICE: END ProcessUtility | Q: do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; | QUERY ID: 6 +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; +NOTICE: START ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 +NOTICE: END ExecutorStart | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 +NOTICE: START ExecutorRun | Q: select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; | QUERY ID: 9 + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +drop function sirv_function(); +drop function not_inlineable_sql_func(i int); +reset client_min_messages; diff --git a/src/test/regress/greenplum_schedule b/src/test/regress/greenplum_schedule index 719ca0c5b24e..41df7af9f115 100755 --- a/src/test/regress/greenplum_schedule +++ b/src/test/regress/greenplum_schedule @@ -361,4 +361,6 @@ test: quicklz_fallback # run pg_hba raleted testing test: hba_conf +test: gp_query_id + # end of tests diff --git a/src/test/regress/sql/gp_query_id.sql b/src/test/regress/sql/gp_query_id.sql new file mode 100644 index 000000000000..393b938fe8f3 --- /dev/null +++ b/src/test/regress/sql/gp_query_id.sql @@ -0,0 +1,137 @@ +-- +-- Test the query command identification +-- +-- start_ignore +create extension if not exists gp_inject_fault; +drop function if exists sirv_function(); +drop function if exists not_inlineable_sql_func(i int); +drop table if exists test_data; +drop table if exists t; +drop table if exists t1; +-- end_ignore + +set client_min_messages = notice; +select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; + +create or replace function sirv_function() returns int as $$ +declare + result int; +begin + create table test_data (x int, y int) with (appendonly=true) distributed by (x); + insert into test_data values (1, 1); + select count(1) into result from test_data; + drop table test_data; + return result; +end $$ language plpgsql; + +\c + +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; + +select sirv_function(); + +-- Test that the query command id is correct after execution of queries in the InitPlan +create table t as select (select sirv_function()) as res distributed by (res); + +-- Test a simple query +select * from t; + +drop table t; + +-- Test a cursor +begin; +declare cur1 cursor for select sirv_function() as res; +fetch 1 from cur1; +fetch all from cur1; +commit; + +-- Test two cursors +begin; +declare cur1_a cursor for select sirv_function() as res; +fetch 1 from cur1_a; +declare cur2_b cursor for select sirv_function() as res; +fetch 2 from cur2_b; +fetch all from cur2_b; +fetch all from cur1_a; +commit; + +-- Test partitioned tables +create table t(i int) distributed by (i) +partition by range (i) (start (1) end (10) every (1), default partition extra); + +alter table t rename to t1; + +drop table t1; + +-- Test a function written in sql language, that optimizers cannot inline +create or replace function not_inlineable_sql_func(i int) returns int +immutable +security definer +as $$ +select case when i > 5 then 1 else 0 end; +$$ language sql; + +select not_inlineable_sql_func(i) from generate_series(1, 10)i; + +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; + +-- Test the query command ids dispatched to segments +-- start_matchsubs +-- m/select pg_catalog.pg_relation_size\(.*\)/ +-- s/select pg_catalog.pg_relation_size\(.*\)/select pg_catalog.pg_relation_size\(\)/ +-- m/select pg_catalog.gp_acquire_sample_rows\(.*\)/ +-- s/select pg_catalog.gp_acquire_sample_rows\(.*\)/select pg_catalog.gp_acquire_sample_rows\(\)/ +-- m/select pg_catalog.gp_acquire_correlations\(.*\)/ +-- s/select pg_catalog.gp_acquire_correlations\(.*\)/select pg_catalog.gp_acquire_correlations\(\)/ +-- end_matchsubs +select gp_inject_fault_infinite('track_query_command_id_at_start', 'skip', dbid) from gp_segment_configuration; + +create table t as select 1; +drop table t; + +create table t (i int, j text) with (appendonly = true) distributed by (i); +insert into t select i, (i + 1)::text from generate_series(1, 100) i; +vacuum analyze t; +drop table t; + +select gp_inject_fault_infinite('track_query_command_id_at_start', 'reset', dbid) from gp_segment_configuration; + +-- Test the query command id after an error has happened +select gp_inject_fault('appendonly_insert', 'panic', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; + +select gp_inject_fault_infinite('track_query_command_id', 'skip', dbid) from gp_segment_configuration +where role = 'p' and content = -1; + +-- First query will fail with an error due to insert inside the function +select sirv_function(); + +select sirv_function(); + +select gp_inject_fault('appendonly_insert', 'reset', '', '', 'test_data', 1, -1, 0, dbid) from gp_segment_configuration +where role = 'p'; + +-- Test an exception caught inside the function +\c +create table t (i int); +insert into t values(0); + +do $$ +declare +j int; +begin + select 1 / i from t into strict j; + raise warning '%', j; + exception when others then raise warning '%', sqlerrm; + raise warning '%', 2; + raise warning '%', 3; +end$$; + +select gp_inject_fault_infinite('track_query_command_id', 'reset', dbid) from gp_segment_configuration +where role = 'p' and content = -1; + +drop function sirv_function(); +drop function not_inlineable_sql_func(i int); +reset client_min_messages; From 652522da4fd265a0df28804e688361925622daf2 Mon Sep 17 00:00:00 2001 From: Dennis Kovalenko Date: Fri, 25 Oct 2024 12:17:06 +0300 Subject: [PATCH 6/8] Fix -Wvla-cxx-extension warning (#1084) --- src/backend/gpopt/translate/CTranslatorUtils.cpp | 8 ++++---- src/backend/gpopt/utils/COptTasks.cpp | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/gpopt/translate/CTranslatorUtils.cpp b/src/backend/gpopt/translate/CTranslatorUtils.cpp index 3423621a78ed..1d2a980a4764 100644 --- a/src/backend/gpopt/translate/CTranslatorUtils.cpp +++ b/src/backend/gpopt/translate/CTranslatorUtils.cpp @@ -387,8 +387,8 @@ CTranslatorUtils::ResolvePolymorphicTypes(CMemoryPool *mp, const ULONG num_args = std::min(num_arg_types, num_args_from_query); const ULONG total_args = num_args + num_return_args; - OID arg_types[total_args]; - char arg_modes[total_args]; + std::vector arg_types(total_args); + std::vector arg_modes(total_args); // copy the first 'num_args' function argument types ListCell *arg_type = nullptr; @@ -410,8 +410,8 @@ CTranslatorUtils::ResolvePolymorphicTypes(CMemoryPool *mp, arg_modes[arg_index++] = PROARGMODE_TABLE; } - if (!gpdb::ResolvePolymorphicArgType(total_args, arg_types, arg_modes, - funcexpr)) + if (!gpdb::ResolvePolymorphicArgType(total_args, arg_types.data(), + arg_modes.data(), funcexpr)) { GPOS_RAISE( gpdxl::ExmaDXL, gpdxl::ExmiDXLUnrecognizedType, diff --git a/src/backend/gpopt/utils/COptTasks.cpp b/src/backend/gpopt/utils/COptTasks.cpp index 541389be2951..56dec50c3a09 100644 --- a/src/backend/gpopt/utils/COptTasks.cpp +++ b/src/backend/gpopt/utils/COptTasks.cpp @@ -987,14 +987,15 @@ COptTasks::PrintMissingStatsWarning(CMemoryPool *mp, CMDAccessor *md_accessor, if (0 < rel_stats->Size()) { - int length = NAMEDATALEN * rel_stats->Size() + 200; - char msgbuf[length]; - snprintf( - msgbuf, sizeof(msgbuf), - "One or more columns in the following table(s) do not have statistics: %s", - CreateMultiByteCharStringFromWCString(wcstr.GetBuffer())); + CWStringDynamic msgbuf(mp); + msgbuf.AppendFormat( + GPOS_WSZ_LIT( + "One or more columns in the following table(s) do not have statistics: %ls"), + wcstr.GetBuffer()); + GpdbEreport( - ERRCODE_SUCCESSFUL_COMPLETION, NOTICE, msgbuf, + ERRCODE_SUCCESSFUL_COMPLETION, NOTICE, + CreateMultiByteCharStringFromWCString(msgbuf.GetBuffer()), "For non-partitioned tables, run analyze ()." " For partitioned tables, run analyze rootpartition ()." " See log for columns missing statistics."); From ac92e1f40eb29f6e300f7ef80994e778df22efde Mon Sep 17 00:00:00 2001 From: Maxim Michkov Date: Thu, 12 Sep 2024 13:55:01 +0300 Subject: [PATCH 7/8] Fix pg_dump incorrect cleanup for external tables (#1045) Fixes issue #1025. DROP EXTERNAL TABLE in pg_dump output had incorrect syntax, this patch fixes the typo. Ticket: ADBDEV-6257 Changes from original commit: 1. Removed tests since this code only affects GPDB 6 compatibility, there is no way to reach this line using only GPDB 7. This is because GPDB 7 uses FOREIGN TABLE instead of EXTERNAL TABLE, so EXTERNAL TABLE cannot appear in GPDB 7 database. Co-authored-by: eshkinkot (cherry picked from commit eaafa97a524e34f6533b5b5ee406fce5bf430d94) --- src/bin/pg_dump/pg_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 0728fa0fbabf..1917f13b4df7 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -16431,7 +16431,7 @@ dumpExternal(Archive *fout, const TableInfo *tbinfo, PQExpBuffer q, PQExpBuffer * DROP must be fully qualified in case same name appears in * pg_catalog */ - appendPQExpBuffer(delq, "DROP EXTERNAL TABLE %s.", + appendPQExpBuffer(delq, "DROP EXTERNAL TABLE %s;\n", qualrelname); /* Now get required information from pg_exttable */ From 69f5f039f69359c9358e510b9697131d77faa1cb Mon Sep 17 00:00:00 2001 From: Dennis Kovalenko Date: Wed, 30 Oct 2024 08:55:56 +0300 Subject: [PATCH 8/8] Fix -Wimplicit-fallthrough warning produced by Clang (#1087) --- contrib/btree_gin/btree_gin.c | 2 +- contrib/isn/isn.c | 1 + contrib/pg_trgm/trgm_gin.c | 12 +- contrib/pg_trgm/trgm_gist.c | 8 +- contrib/pgcrypto/imath.c | 3 +- contrib/pgcrypto/pgp-info.c | 2 +- contrib/postgres_fdw/deparse.c | 4 - contrib/postgres_fdw/postgres_fdw.c | 2 +- gpcontrib/gp_sparse_vector/operators.c | 2 +- src/backend/access/heap/heapam_handler.c | 2 +- src/backend/access/transam/xlog.c | 1 + src/backend/catalog/dependency.c | 2 +- src/backend/catalog/objectaddress.c | 2 +- src/backend/cdb/cdbtm.c | 2 +- src/backend/commands/explain.c | 2 +- src/backend/commands/tablecmds.c | 2 +- src/backend/commands/trigger.c | 2 +- src/backend/executor/nodeAgg.c | 2 +- src/backend/executor/nodeHash.c | 14 +- src/backend/executor/nodeHashjoin.c | 10 +- src/backend/executor/nodeLimit.c | 2 +- src/backend/fts/ftsprobe.c | 2 +- src/backend/jit/llvm/llvmjit_expr.c | 8 +- src/backend/libpq/auth.c | 2 +- src/backend/optimizer/util/clauses.c | 4 +- src/backend/parser/parse_utilcmd.c | 2 +- src/backend/partitioning/partprune.c | 8 +- src/backend/postmaster/postmaster.c | 5 +- src/backend/regex/regc_lex.c | 2 +- src/backend/regex/regc_pg_locale.c | 44 +++--- src/backend/regex/regcomp.c | 2 +- .../replication/logical/reorderbuffer.c | 2 +- src/backend/replication/walreceiver.c | 2 +- src/backend/replication/walreceiverfuncs.c | 2 +- src/backend/tcop/postgres.c | 6 +- src/backend/tcop/utility.c | 2 +- src/backend/utils/adt/datetime.c | 8 +- src/backend/utils/adt/formatting.c | 3 +- src/backend/utils/adt/jsonb_util.c | 2 +- src/backend/utils/adt/jsonpath.c | 11 +- src/backend/utils/adt/numeric.c | 6 +- src/backend/utils/adt/ruleutils.c | 3 +- src/backend/utils/adt/timestamp.c | 54 +++---- src/backend/utils/adt/tsginidx.c | 2 +- src/backend/utils/cache/catcache.c | 12 +- src/backend/utils/cache/lsyscache.c | 1 - src/backend/utils/datumstream/datumstream.c | 2 +- .../utils/datumstream/datumstreamblock.c | 1 - src/backend/utils/fmgr/funcapi.c | 1 - src/backend/utils/hash/dynahash.c | 1 - .../utils/hyperloglog/gp_hyperloglog.c | 12 +- .../conversion_procs/euc_tw_and_big5/big5.c | 2 - src/backend/utils/mb/wchar.c | 12 +- src/backend/utils/misc/guc.c | 4 +- src/backend/utils/resscheduler/resscheduler.c | 2 +- src/backend/utils/sort/tuplestore.c | 2 +- src/bin/pg_rewind/pg_rewind.c | 2 +- src/common/hashfn.c | 144 +++++++++--------- src/include/c.h | 14 ++ src/interfaces/ecpg/pgtypeslib/interval.c | 6 +- src/interfaces/ecpg/preproc/ecpg.c | 2 +- src/interfaces/libpq/fe-secure.c | 2 +- src/pl/plperl/plperl.h | 14 +- src/pl/plpgsql/src/pl_comp.c | 2 +- src/pl/plpgsql/src/pl_exec.c | 6 +- src/pl/tcl/pltcl.c | 2 +- src/port/glob.c | 2 +- src/port/snprintf.c | 2 +- src/timezone/zic.c | 8 +- 69 files changed, 265 insertions(+), 254 deletions(-) diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c index c7b217288f26..88bb460082d0 100644 --- a/contrib/btree_gin/btree_gin.c +++ b/contrib/btree_gin/btree_gin.c @@ -89,7 +89,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo, case BTGreaterEqualStrategyNumber: case BTGreaterStrategyNumber: *ptr_partialmatch = true; - /* FALLTHROUGH */ + fallthru; case BTEqualStrategyNumber: entries[0] = datum; break; diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index 0c2cac7d52bf..f3faf4a9e9c5 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -852,6 +852,7 @@ string2ean(const char *str, bool errorOK, ean13 *result, case UPC: buf[2] = '0'; valid = (valid && ((rcheck = checkdig(buf + 2, 13)) == check || magic)); + fallthru; default: break; } diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c index 1b9809b565a3..8026a41191ee 100644 --- a/contrib/pg_trgm/trgm_gin.c +++ b/contrib/pg_trgm/trgm_gin.c @@ -97,7 +97,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case LikeStrategyNumber: /* @@ -111,7 +111,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case RegExpStrategyNumber: trg = createTrgmNFA(val, PG_GET_COLLATION(), &graph, CurrentMemoryContext); @@ -221,7 +221,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case LikeStrategyNumber: /* Check if all extracted trigrams are presented. */ res = true; @@ -238,7 +238,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case RegExpStrategyNumber: if (nkeys < 1) { @@ -306,7 +306,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case LikeStrategyNumber: /* Check if all extracted trigrams are presented. */ res = GIN_MAYBE; @@ -323,7 +323,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case RegExpStrategyNumber: if (nkeys < 1) { diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 6e1cb7ec9fc1..fbaaed8de587 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -210,7 +210,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case LikeStrategyNumber: qtrg = generate_wildcard_trgm(VARDATA(query), querysize - VARHDRSZ); @@ -219,7 +219,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case RegExpStrategyNumber: qtrg = createTrgmNFA(query, PG_GET_COLLATION(), &graph, fcinfo->flinfo->fn_mcxt); @@ -307,7 +307,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case LikeStrategyNumber: /* Wildcard search is inexact */ *recheck = true; @@ -348,7 +348,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + fallthru; case RegExpStrategyNumber: /* Regexp search is inexact */ *recheck = true; diff --git a/contrib/pgcrypto/imath.c b/contrib/pgcrypto/imath.c index d5fb2929e5e6..b08d1b37362c 100644 --- a/contrib/pgcrypto/imath.c +++ b/contrib/pgcrypto/imath.c @@ -1978,7 +1978,8 @@ mp_int_read_cstring(mp_int z, mp_size radix, const char *str, ++str; break; case '+': - ++str; /* fallthrough */ + ++str; + fallthru; default: z->sign = MP_ZPOS; break; diff --git a/contrib/pgcrypto/pgp-info.c b/contrib/pgcrypto/pgp-info.c index 9bfbbe6d0c98..6777ca9d0f14 100644 --- a/contrib/pgcrypto/pgp-info.c +++ b/contrib/pgcrypto/pgp-info.c @@ -169,7 +169,7 @@ pgp_get_keyid(MBuf *pgp_data, char *dst) break; case PGP_PKT_SYMENCRYPTED_SESSKEY: got_symenc_key++; - /* fallthru */ + fallthru; case PGP_PKT_SIGNATURE: case PGP_PKT_MARKER: case PGP_PKT_TRUST: diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index 11726ac8a527..92266151323a 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -3101,13 +3101,10 @@ deparsePartialAggFunctionParamFilter(Aggref *node, deparse_expr_cxt *context, { case 2100: /* int8 AVG */ - /* Fall through */ case 2101: /* int4 AVG function */ - /* Fall through */ case 2102: /* int2 AVG function */ - /* Fall through */ case 2103: /* numeric AVG function */ /* According to aggcombinefn, those aggregate functions need to fetch same columns from remote server. */ @@ -3116,7 +3113,6 @@ deparsePartialAggFunctionParamFilter(Aggref *node, deparse_expr_cxt *context, break; case 2104: /* float4 AVG function */ - /* Fall through */ case 2105: /* float8 AVG function */ appendStringInfo(buf, "array[count(%s)%s, sum(%s)%s, count(%s)*var_pop(%s)%s]", diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 8744bba586a6..eecbfde7e8b7 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -6350,7 +6350,7 @@ postgresGetForeignUpperPaths(PlannerInfo *root, UpperRelationKind stage, /* It's unsafe to push having statements with partial aggregates */ if (((GroupPathExtraData *) extra)->havingQual) return; - /* Fall through */ + fallthru; /* Partial agg push down path */ case UPPERREL_GROUP_AGG: add_foreign_grouping_paths(root, input_rel, output_rel, diff --git a/gpcontrib/gp_sparse_vector/operators.c b/gpcontrib/gp_sparse_vector/operators.c index 6c85dc2acf12..d8dcec95f95d 100644 --- a/gpcontrib/gp_sparse_vector/operators.c +++ b/gpcontrib/gp_sparse_vector/operators.c @@ -411,7 +411,7 @@ svec_count(PG_FUNCTION_ARGS) * beginning of the accumulation of the correct dimension. */ left = makeSparseDataFromDouble(0.,right->total_value_count); - /* FALLTHROUGH */ + fallthru; case 0: //neither arg is scalar case 2: //right arg is scalar diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 187813ed5049..7a982da77cba 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -917,7 +917,7 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap, break; case HEAPTUPLE_RECENTLY_DEAD: *tups_recently_dead += 1; - /* fall through */ + fallthru; case HEAPTUPLE_LIVE: /* Live or recently dead, must copy it */ isdead = false; diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index cc0117efe312..776c89d17282 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7757,6 +7757,7 @@ StartupXLOG(void) recoveryPausesHere(); /* drop into promote */ + fallthru; case RECOVERY_TARGET_ACTION_PROMOTE: break; diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index 761c4108aaaf..c9ddc616f0d2 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -639,7 +639,7 @@ findDependentObjects(const ObjectAddress *object, break; /* Otherwise, treat this like an internal dependency */ - /* FALL THRU */ + fallthru; case DEPENDENCY_INTERNAL: diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 87716d7f103d..dd2fd27c925d 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2172,7 +2172,7 @@ pg_get_object_address(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("name list length must be at least %d", 3))); /* fall through to check args length */ - /* FALLTHROUGH */ + fallthru; case OBJECT_OPERATOR: if (list_length(args) != 2) ereport(ERROR, diff --git a/src/backend/cdb/cdbtm.c b/src/backend/cdb/cdbtm.c index 06254cc9fb4a..eeb08fc9a638 100644 --- a/src/backend/cdb/cdbtm.c +++ b/src/backend/cdb/cdbtm.c @@ -825,7 +825,7 @@ doNotifyingAbort(void) setCurrentDtxState(DTX_STATE_RETRY_ABORT_PREPARED); setDistributedTransactionContext(DTX_CONTEXT_QD_RETRY_PHASE_2); } - /* FALL THRU */ + fallthru; case DTX_STATE_RETRY_ABORT_PREPARED: retryAbortPrepared(); diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index c5996c438842..6884214e2ced 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -2352,7 +2352,7 @@ ExplainNode(PlanState *planstate, List *ancestors, show_tablesample(((SampleScan *) plan)->tablesample, planstate, ancestors, es); /* fall through to print additional fields the same as SeqScan */ - /* FALLTHROUGH */ + fallthru; case T_SeqScan: case T_DynamicSeqScan: case T_ValuesScan: diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 00a727511b3e..2c9a9bd71c18 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14587,7 +14587,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock case RELKIND_AOVISIMAP: if (recursing) break; - /* FALL THRU */ + fallthru; default: ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 50c90f86aa08..5ed0b59b50b7 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -4381,7 +4381,7 @@ AfterTriggerExecute(EState *estate, trig_tuple_slot2)) elog(ERROR, "failed to fetch tuple2 for AFTER trigger"); } - /* fall through */ + fallthru; case AFTER_TRIGGER_FDW_REUSE: /* diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 9808a3c127d2..7ed7d6a76f9e 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -2326,7 +2326,7 @@ ExecAgg(PlanState *pstate) case AGG_HASHED: if (!node->table_filled) agg_fill_hash_table(node); - /* FALLTHROUGH */ + fallthru; case AGG_MIXED: result = agg_retrieve_hash_table(node); break; diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index b25e3a79821d..29ca405de7f7 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -291,7 +291,7 @@ MultiExecParallelHash(HashState *node) * way, wait for everyone to arrive here so we can proceed. */ BarrierArriveAndWait(build_barrier, WAIT_EVENT_HASH_BUILD_ALLOCATING); - /* Fall through. */ + fallthru; case PHJ_BUILD_HASHING_INNER: @@ -1349,13 +1349,13 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) /* All other participants just flush their tuples to disk. */ ExecParallelHashCloseBatchAccessors(hashtable); } - /* Fall through. */ + fallthru; case PHJ_GROW_BATCHES_ALLOCATING: /* Wait for the above to be finished. */ BarrierArriveAndWait(&pstate->grow_batches_barrier, WAIT_EVENT_HASH_GROW_BATCHES_ALLOCATING); - /* Fall through. */ + fallthru; case PHJ_GROW_BATCHES_REPARTITIONING: /* Make sure that we have the current dimensions and buckets. */ @@ -1368,7 +1368,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) /* Wait for the above to be finished. */ BarrierArriveAndWait(&pstate->grow_batches_barrier, WAIT_EVENT_HASH_GROW_BATCHES_REPARTITIONING); - /* Fall through. */ + fallthru; case PHJ_GROW_BATCHES_DECIDING: @@ -1423,7 +1423,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) dsa_free(hashtable->area, pstate->old_batches); pstate->old_batches = InvalidDsaPointer; } - /* Fall through. */ + fallthru; case PHJ_GROW_BATCHES_FINISHING: /* Wait for the above to complete. */ @@ -1701,13 +1701,13 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable) /* Clear the flag. */ pstate->growth = PHJ_GROWTH_OK; } - /* Fall through. */ + fallthru; case PHJ_GROW_BUCKETS_ALLOCATING: /* Wait for the above to complete. */ BarrierArriveAndWait(&pstate->grow_buckets_barrier, WAIT_EVENT_HASH_GROW_BUCKETS_ALLOCATING); - /* Fall through. */ + fallthru; case PHJ_GROW_BUCKETS_REINSERTING: /* Reinsert all tuples into the hash table. */ diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 149a22f0f3ee..3a3475845d2d 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -417,7 +417,7 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel) else node->hj_JoinState = HJ_NEED_NEW_OUTER; - /* FALL THRU */ + fallthru; case HJ_NEED_NEW_OUTER: @@ -511,7 +511,7 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel) /* OK, let's scan the bucket for matches */ node->hj_JoinState = HJ_SCAN_BUCKET; - /* FALL THRU */ + fallthru; case HJ_SCAN_BUCKET: @@ -1389,13 +1389,13 @@ ExecParallelHashJoinNewBatch(HashJoinState *hjstate) if (BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_ELECTING)) ExecParallelHashTableAlloc(hashtable, batchno); - /* Fall through. */ + fallthru; case PHJ_BATCH_ALLOCATING: /* Wait for allocation to complete. */ BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_ALLOCATING); - /* Fall through. */ + fallthru; case PHJ_BATCH_LOADING: /* Start (or join in) loading tuples. */ @@ -1415,7 +1415,7 @@ ExecParallelHashJoinNewBatch(HashJoinState *hjstate) sts_end_parallel_scan(inner_tuples); BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_LOADING); - /* Fall through. */ + fallthru; case PHJ_BATCH_PROBING: diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index ab15acd22513..694c64152804 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -71,7 +71,7 @@ ExecLimit_guts(PlanState *pstate) */ recompute_limits(node); - /* FALL THRU */ + fallthru; case LIMIT_RESCAN: diff --git a/src/backend/fts/ftsprobe.c b/src/backend/fts/ftsprobe.c index 5696976c4232..161aa4f9555d 100644 --- a/src/backend/fts/ftsprobe.c +++ b/src/backend/fts/ftsprobe.c @@ -859,7 +859,7 @@ processRetry(fts_context *context) if (!(ftsInfo->result.retryRequested && context->has_mirrors && SEGMENT_IS_ALIVE(ftsInfo->mirror_cdbinfo))) break; - /* else, fallthrough */ + fallthru; case FTS_PROBE_FAILED: case FTS_SYNCREP_OFF_FAILED: case FTS_PROMOTE_FAILED: diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c index 5ee7bb57d71f..48bb4d0b4ab9 100644 --- a/src/backend/jit/llvm/llvmjit_expr.c +++ b/src/backend/jit/llvm/llvmjit_expr.c @@ -664,7 +664,7 @@ llvm_compile_expr(ExprState *state) LLVMPositionBuilderAtEnd(b, b_nonull); } - /* FALLTHROUGH */ + fallthru; case EEOP_FUNCEXPR: { @@ -703,7 +703,7 @@ llvm_compile_expr(ExprState *state) LLVMBuildStore(b, l_sbool_const(0), v_boolanynullp); } - /* FALLTHROUGH */ + fallthru; /* * Treat them the same for now, optimizer can remove @@ -804,7 +804,7 @@ llvm_compile_expr(ExprState *state) l_ptr(TypeStorageBool)); LLVMBuildStore(b, l_sbool_const(0), v_boolanynullp); } - /* FALLTHROUGH */ + fallthru; /* * Treat them the same for now, optimizer can remove @@ -2111,7 +2111,7 @@ llvm_compile_expr(ExprState *state) b_deserialize); LLVMPositionBuilderAtEnd(b, b_deserialize); } - /* FALLTHROUGH */ + fallthru; case EEOP_AGG_DESERIALIZE: { diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index cba61dc6fd91..f0e79d31f1c8 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -2467,7 +2467,7 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, ereport(LOG, (errmsg("error from underlying PAM layer: %s", msg[i]->msg))); - /* FALL THROUGH */ + fallthru; case PAM_TEXT_INFO: /* we don't bother to log TEXT_INFO messages */ if ((reply[i].resp = strdup("")) == NULL) diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index a21dcfa62222..ba698dff532a 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -1714,7 +1714,7 @@ find_nonnullable_rels_walker(Node *node, bool top_level) * the intersection of the sets of nonnullable rels, just as * for OR. Fall through to share code. */ - /* FALL THRU */ + fallthru; case OR_EXPR: /* @@ -1939,7 +1939,7 @@ find_nonnullable_vars_walker(Node *node, bool top_level) * the intersection of the sets of nonnullable vars, just as * for OR. Fall through to share code. */ - /* FALL THRU */ + fallthru; case OR_EXPR: /* diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 6ac85d726900..f42d6cb75aba 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -852,7 +852,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) errmsg("primary key constraints are not supported on foreign tables"), parser_errposition(cxt->pstate, constraint->location))); - /* FALL THRU */ + fallthru; case CONSTR_UNIQUE: if (cxt->isforeign) diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index 695baa496a42..a2843d900481 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -2712,7 +2712,7 @@ get_matching_list_bounds(PartitionPruneContext *context, case BTGreaterEqualStrategyNumber: inclusive = true; - /* fall through */ + fallthru; case BTGreaterStrategyNumber: off = partition_list_bsearch(partsupfunc, partcollation, @@ -2747,7 +2747,7 @@ get_matching_list_bounds(PartitionPruneContext *context, case BTLessEqualStrategyNumber: inclusive = true; - /* fall through */ + fallthru; case BTLessStrategyNumber: off = partition_list_bsearch(partsupfunc, partcollation, @@ -2994,7 +2994,7 @@ get_matching_range_bounds(PartitionPruneContext *context, case BTGreaterEqualStrategyNumber: inclusive = true; - /* fall through */ + fallthru; case BTGreaterStrategyNumber: /* @@ -3075,7 +3075,7 @@ get_matching_range_bounds(PartitionPruneContext *context, case BTLessEqualStrategyNumber: inclusive = true; - /* fall through */ + fallthru; case BTLessStrategyNumber: /* diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 4af867f5f9b2..1f5d08b23556 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -6515,19 +6515,18 @@ bgworker_should_start_now(BgWorkerStartTime start_time) return true; if (start_time == BgWorkerStart_RecoveryFinished) return true; - /* fall through */ + fallthru; case PM_HOT_STANDBY: if (start_time == BgWorkerStart_ConsistentState) return true; - /* fall through */ + fallthru; case PM_RECOVERY: case PM_STARTUP: case PM_INIT: if (start_time == BgWorkerStart_PostmasterStart) return true; - /* fall through */ } diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c index 16664531641c..2426de1f789c 100644 --- a/src/backend/regex/regc_lex.c +++ b/src/backend/regex/regc_lex.c @@ -875,7 +875,7 @@ lexescape(struct vars *v) /* oops, doesn't look like it's a backref after all... */ v->now = save; /* and fall through into octal number */ - /* FALLTHROUGH */ + fallthru; case CHR('0'): NOTE(REG_UUNPORT); v->now--; /* put first digit back */ diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c index 4a808b7606cf..887da6580f2e 100644 --- a/src/backend/regex/regc_pg_locale.c +++ b/src/backend/regex/regc_pg_locale.c @@ -303,7 +303,7 @@ pg_wc_isdigit(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswdigit((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isdigit((unsigned char) c)); @@ -312,7 +312,7 @@ pg_wc_isdigit(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswdigit_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -339,7 +339,7 @@ pg_wc_isalpha(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalpha((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isalpha((unsigned char) c)); @@ -348,7 +348,7 @@ pg_wc_isalpha(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalpha_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -375,7 +375,7 @@ pg_wc_isalnum(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalnum((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isalnum((unsigned char) c)); @@ -384,7 +384,7 @@ pg_wc_isalnum(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalnum_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -411,7 +411,7 @@ pg_wc_isupper(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswupper((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isupper((unsigned char) c)); @@ -420,7 +420,7 @@ pg_wc_isupper(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswupper_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -447,7 +447,7 @@ pg_wc_islower(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswlower((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && islower((unsigned char) c)); @@ -456,7 +456,7 @@ pg_wc_islower(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswlower_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -483,7 +483,7 @@ pg_wc_isgraph(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswgraph((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isgraph((unsigned char) c)); @@ -492,7 +492,7 @@ pg_wc_isgraph(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswgraph_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -519,7 +519,7 @@ pg_wc_isprint(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswprint((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isprint((unsigned char) c)); @@ -528,7 +528,7 @@ pg_wc_isprint(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswprint_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -555,7 +555,7 @@ pg_wc_ispunct(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswpunct((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && ispunct((unsigned char) c)); @@ -564,7 +564,7 @@ pg_wc_ispunct(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswpunct_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -591,7 +591,7 @@ pg_wc_isspace(pg_wchar c) case PG_REGEX_LOCALE_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswspace((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isspace((unsigned char) c)); @@ -600,7 +600,7 @@ pg_wc_isspace(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswspace_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && @@ -631,7 +631,7 @@ pg_wc_toupper(pg_wchar c) return pg_ascii_toupper((unsigned char) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towupper((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: /* force C behavior for ASCII characters, per comments above */ if (c <= (pg_wchar) 127) @@ -644,7 +644,7 @@ pg_wc_toupper(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towupper_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T if (c <= (pg_wchar) UCHAR_MAX) @@ -675,7 +675,7 @@ pg_wc_tolower(pg_wchar c) return pg_ascii_tolower((unsigned char) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower((wint_t) c); - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE: /* force C behavior for ASCII characters, per comments above */ if (c <= (pg_wchar) 127) @@ -688,7 +688,7 @@ pg_wc_tolower(pg_wchar c) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower_l((wint_t) c, pg_regex_locale->info.lt); #endif - /* FALL THRU */ + fallthru; case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T if (c <= (pg_wchar) UCHAR_MAX) diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 0de7becabcff..858b22fb111f 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -910,7 +910,7 @@ parseqatom(struct vars *v, /* legal in EREs due to specification botch */ NOTE(REG_UPBOTCH); /* fall through into case PLAIN */ - /* FALLTHROUGH */ + fallthru; case PLAIN: onechr(v, v->nextvalue, lp, rp); okcolors(v->nfa, v->cm); diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 475f76fa5e0e..1df5b0b902ac 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -1540,7 +1540,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, change = specinsert; change->action = REORDER_BUFFER_CHANGE_INSERT; - /* intentionally fall through */ + fallthru; case REORDER_BUFFER_CHANGE_INSERT: case REORDER_BUFFER_CHANGE_UPDATE: case REORDER_BUFFER_CHANGE_DELETE: diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index fe3f71f6877d..d67b9aac478c 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -207,7 +207,7 @@ WalReceiverMain(void) case WALRCV_STOPPING: /* If we've already been requested to stop, don't start up. */ walrcv->walRcvState = WALRCV_STOPPED; - /* fall through */ + fallthru; case WALRCV_STOPPED: SpinLockRelease(&walrcv->mutex); diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c index f85fa220868e..b18375e4e76c 100644 --- a/src/backend/replication/walreceiverfuncs.c +++ b/src/backend/replication/walreceiverfuncs.c @@ -201,7 +201,7 @@ ShutdownWalRcv(void) case WALRCV_WAITING: case WALRCV_RESTARTING: walrcv->walRcvState = WALRCV_STOPPING; - /* fall through */ + fallthru; case WALRCV_STOPPING: walrcvpid = walrcv->pid; break; diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index beb70b721301..01172eebeb78 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3707,7 +3707,7 @@ RecoveryConflictInterrupt(ProcSignalReason reason) return; /* Intentional fall through to check wait for pin */ - /* FALLTHROUGH */ + fallthru; case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN: @@ -3733,7 +3733,7 @@ RecoveryConflictInterrupt(ProcSignalReason reason) MyProc->recoveryConflictPending = true; /* Intentional fall through to error handling */ - /* FALLTHROUGH */ + fallthru; case PROCSIG_RECOVERY_CONFLICT_LOCK: case PROCSIG_RECOVERY_CONFLICT_TABLESPACE: @@ -3778,7 +3778,7 @@ RecoveryConflictInterrupt(ProcSignalReason reason) } /* Intentional fall through to session cancel */ - /* FALLTHROUGH */ + fallthru; case PROCSIG_RECOVERY_CONFLICT_DATABASE: RecoveryConflictPending = true; diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index dd79899ac69f..61115e686166 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -2272,7 +2272,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel) if (stmt->concurrent && Gp_role != GP_ROLE_EXECUTE) PreventInTransactionBlock(isTopLevel, "DROP INDEX CONCURRENTLY"); - /* fall through */ + fallthru; case OBJECT_TABLE: case OBJECT_SEQUENCE: diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 65dd09fdfef0..62a2d6c8e417 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -1882,8 +1882,6 @@ DecodeTimeOnly(char **field, int *ftype, int nf, case DTK_DAY: if (tzp == NULL) return DTERR_BAD_FORMAT; - default: - break; } errno = 0; @@ -3141,7 +3139,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, * handle signed float numbers and signed year-month values. */ - /* FALLTHROUGH */ + fallthru; case DTK_DATE: case DTK_NUMBER: @@ -3572,7 +3570,7 @@ DecodeISO8601Interval(char *str, continue; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + fallthru; case '-': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -3651,7 +3649,7 @@ DecodeISO8601Interval(char *str, return 0; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + fallthru; case ':': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 0d23efa622a2..aa09b3c895ec 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1120,7 +1120,7 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n) case NUM_D: num->flag |= NUM_F_LDECIMAL; num->need_locale = true; - /* FALLTHROUGH */ + fallthru; case NUM_DEC: if (IS_DECIMAL(num)) ereport(ERROR, @@ -2973,7 +2973,6 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col s += strlen(s); break; case DCH_RM: - /* FALLTHROUGH */ case DCH_rm: /* diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c index ba964f68a91d..d8f677279746 100644 --- a/src/backend/utils/adt/jsonb_util.c +++ b/src/backend/utils/adt/jsonb_util.c @@ -595,7 +595,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq, break; case WJB_END_OBJECT: uniqueifyJsonbObject(&(*pstate)->contVal); - /* fall through! */ + fallthru; case WJB_END_ARRAY: /* Steps here common to WJB_END_OBJECT case */ Assert(!scalarVal); diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c index 7f322485e7b1..a61f4228ddef 100644 --- a/src/backend/utils/adt/jsonpath.c +++ b/src/backend/utils/adt/jsonpath.c @@ -331,7 +331,7 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item, break; case jpiFilter: argNestingLevel++; - /* FALLTHROUGH */ + fallthru; case jpiIsUnknown: case jpiNot: case jpiPlus: @@ -440,15 +440,12 @@ alignStringInfoInt(StringInfo buf) { case 3: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ + fallthru; case 2: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ + fallthru; case 1: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ - default: - break; } } @@ -855,7 +852,7 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos) case jpiString: case jpiVariable: read_int32(v->content.value.datalen, base, pos); - /* FALLTHROUGH */ + fallthru; case jpiNumeric: case jpiBool: v->content.value.data = base + pos; diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index a3cca5e6400a..b9ed9e184de2 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -1939,13 +1939,13 @@ numeric_abbrev_convert_var(const NumericVar *var, NumericSortSupport *nss) { default: result |= ((int64) var->digits[3]); - /* FALLTHROUGH */ + fallthru; case 3: result |= ((int64) var->digits[2]) << 14; - /* FALLTHROUGH */ + fallthru; case 2: result |= ((int64) var->digits[1]) << 28; - /* FALLTHROUGH */ + fallthru; case 1: result |= ((int64) var->digits[0]) << 42; break; diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index fc0744b64292..e9f34f336e3a 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -7810,7 +7810,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) } /* else do the same stuff as for T_SubLink et al. */ } - /* FALLTHROUGH */ + fallthru; case T_SubLink: case T_NullTest: @@ -10563,7 +10563,6 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) break; case RTE_TABLEFUNCTION: /* Table Function RTE */ - /* fallthrough */ case RTE_FUNCTION: /* Function RTE */ rtfunc1 = (RangeTblFunction *) linitial(rte->functions); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 52f0a67e9408..b0ed21de03f8 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -4533,14 +4533,14 @@ timestamp_trunc(PG_FUNCTION_ARGS) tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; else tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1; - /* FALL THRU */ + fallthru; case DTK_CENTURY: /* see comments in timestamptz_trunc */ if (tm->tm_year > 0) tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99; else tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1; - /* FALL THRU */ + fallthru; case DTK_DECADE: /* see comments in timestamptz_trunc */ if (val != DTK_MILLENNIUM && val != DTK_CENTURY) @@ -4550,25 +4550,25 @@ timestamp_trunc(PG_FUNCTION_ARGS) else tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10; } - /* FALL THRU */ + fallthru; case DTK_YEAR: tm->tm_mon = 1; - /* FALL THRU */ + fallthru; case DTK_QUARTER: tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1; - /* FALL THRU */ + fallthru; case DTK_MONTH: tm->tm_mday = 1; - /* FALL THRU */ + fallthru; case DTK_DAY: tm->tm_hour = 0; - /* FALL THRU */ + fallthru; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + fallthru; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + fallthru; case DTK_SECOND: fsec = 0; break; @@ -4674,14 +4674,14 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp) tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; else tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1; - /* FALL THRU */ + fallthru; case DTK_CENTURY: /* truncating to the century? as above: -100, 1, 101... */ if (tm->tm_year > 0) tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99; else tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1; - /* FALL THRU */ + fallthru; case DTK_DECADE: /* @@ -4695,26 +4695,26 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp) else tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10; } - /* FALL THRU */ + fallthru; case DTK_YEAR: tm->tm_mon = 1; - /* FALL THRU */ + fallthru; case DTK_QUARTER: tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1; - /* FALL THRU */ + fallthru; case DTK_MONTH: tm->tm_mday = 1; - /* FALL THRU */ + fallthru; case DTK_DAY: tm->tm_hour = 0; redotz = true; /* for all cases >= DAY */ - /* FALL THRU */ + fallthru; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + fallthru; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + fallthru; case DTK_SECOND: fsec = 0; break; @@ -4862,33 +4862,33 @@ interval_trunc(PG_FUNCTION_ARGS) case DTK_MILLENNIUM: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 1000) * 1000; - /* FALL THRU */ + fallthru; case DTK_CENTURY: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 100) * 100; - /* FALL THRU */ + fallthru; case DTK_DECADE: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 10) * 10; - /* FALL THRU */ + fallthru; case DTK_YEAR: tm->tm_mon = 0; - /* FALL THRU */ + fallthru; case DTK_QUARTER: tm->tm_mon = 3 * (tm->tm_mon / 3); - /* FALL THRU */ + fallthru; case DTK_MONTH: tm->tm_mday = 0; - /* FALL THRU */ + fallthru; case DTK_DAY: tm->tm_hour = 0; - /* FALL THRU */ + fallthru; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + fallthru; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + fallthru; case DTK_SECOND: fsec = 0; break; diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index 81422c8e85aa..a41a80a1652e 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -264,7 +264,7 @@ TS_execute_ternary(GinChkVal *gcv, QueryItem *curitem, bool in_phrase) /* Pass down in_phrase == true in case there's a NOT below */ in_phrase = true; - /* FALL THRU */ + fallthru; case OP_AND: val1 = TS_execute_ternary(gcv, curitem + curitem->qoperator.left, diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index cd9d606158e8..7a51b2e810a7 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -285,19 +285,19 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys, hashValue ^= oneHash << 24; hashValue ^= oneHash >> 8; - /* FALLTHROUGH */ + fallthru; case 3: oneHash = (cc_hashfunc[2]) (v3); hashValue ^= oneHash << 16; hashValue ^= oneHash >> 16; - /* FALLTHROUGH */ + fallthru; case 2: oneHash = (cc_hashfunc[1]) (v2); hashValue ^= oneHash << 8; hashValue ^= oneHash >> 24; - /* FALLTHROUGH */ + fallthru; case 1: oneHash = (cc_hashfunc[0]) (v1); @@ -336,21 +336,21 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, int nkeys, HeapTuple tuple) cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + fallthru; case 3: v3 = fastgetattr(tuple, cc_keyno[2], cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + fallthru; case 2: v2 = fastgetattr(tuple, cc_keyno[1], cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + fallthru; case 1: v1 = fastgetattr(tuple, cc_keyno[0], diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index c9be886de26e..f17d1a75dcb9 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -1714,7 +1714,6 @@ trigger_enabled(Oid triggerid) switch (tgenabled) { case TRIGGER_FIRES_ON_ORIGIN: - /* fallthrough */ /* * FIXME: we should probably return false when * SessionReplicationRole isn't SESSION_REPLICATION_ROLE_ORIGIN, diff --git a/src/backend/utils/datumstream/datumstream.c b/src/backend/utils/datumstream/datumstream.c index 988077fc7b82..1b78432c556f 100644 --- a/src/backend/utils/datumstream/datumstream.c +++ b/src/backend/utils/datumstream/datumstream.c @@ -178,7 +178,7 @@ datumstreamread_getlarge(DatumStreamRead * acc, Datum *datum, bool *null) acc->largeObjectState = DatumStreamLargeObjectState_Consumed; /* Fall below to ~_Consumed. */ - /* fallthrough */ + fallthru; case DatumStreamLargeObjectState_Consumed: { diff --git a/src/backend/utils/datumstream/datumstreamblock.c b/src/backend/utils/datumstream/datumstreamblock.c index 4b6e588e7715..f057baff954b 100755 --- a/src/backend/utils/datumstream/datumstreamblock.c +++ b/src/backend/utils/datumstream/datumstreamblock.c @@ -3476,7 +3476,6 @@ DatumStreamBlockWrite_PutDense( return -1; case DELTA_COMPRESSION_NOT_APPLIED: break; - /* FALL through */ } } diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index 38a0dea20b54..29f3ebb978e2 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -1396,7 +1396,6 @@ build_function_result_tupdesc_d(char prokind, /* input and output */ case PROARGMODE_INOUT: - /* fallthrough */ /* output modes */ case PROARGMODE_OUT: diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index b36606355123..a00b3c53d56c 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -1039,7 +1039,6 @@ hash_search_with_hash_value(HTAB *hashp, return NULL; case HASH_ENTER_NULL: - /* FALL THRU */ case HASH_ENTER: /* Return existing element if found, else create one */ diff --git a/src/backend/utils/hyperloglog/gp_hyperloglog.c b/src/backend/utils/hyperloglog/gp_hyperloglog.c index 7d3c879ec2a7..2bd14c0999f8 100644 --- a/src/backend/utils/hyperloglog/gp_hyperloglog.c +++ b/src/backend/utils/hyperloglog/gp_hyperloglog.c @@ -908,17 +908,17 @@ GpMurmurHash64A (const void * key, int len, unsigned int seed) switch(len & 7) { case 7: h ^= (uint64_t)data[6] << 48; - /* fallthrough */ + fallthru; case 6: h ^= (uint64_t)data[5] << 40; - /* fallthrough */ + fallthru; case 5: h ^= (uint64_t)data[4] << 32; - /* fallthrough */ + fallthru; case 4: h ^= (uint64_t)data[3] << 24; - /* fallthrough */ + fallthru; case 3: h ^= (uint64_t)data[2] << 16; - /* fallthrough */ + fallthru; case 2: h ^= (uint64_t)data[1] << 8; - /* fallthrough */ + fallthru; case 1: h ^= (uint64_t)data[0]; h *= m; }; diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c index 68f76aa8cb82..9e9a8356dfd4 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c @@ -370,8 +370,6 @@ CNStoBIG5(unsigned short cns, unsigned char lc) if (b1c4[i][1] == cns) return b1c4[i][0]; } - default: - break; } return big5; } diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 1b5ce1740c0f..78f2d91feacb 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1516,12 +1516,12 @@ pg_utf8_islegal(const unsigned char *source, int length) a = source[3]; if (a < 0x80 || a > 0xBF) return false; - /* FALL THRU */ + fallthru; case 3: a = source[2]; if (a < 0x80 || a > 0xBF) return false; - /* FALL THRU */ + fallthru; case 2: a = source[1]; switch (*source) @@ -1547,7 +1547,7 @@ pg_utf8_islegal(const unsigned char *source, int length) return false; break; } - /* FALL THRU */ + fallthru; case 1: a = *source; if (a >= 0x80 && a < 0xC2) @@ -1623,7 +1623,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[3]++; break; } - /* FALL THRU */ + fallthru; case 3: a = charptr[2]; if (a < 0xBF) @@ -1631,7 +1631,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[2]++; break; } - /* FALL THRU */ + fallthru; case 2: a = charptr[1]; switch (*charptr) @@ -1651,7 +1651,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[1]++; break; } - /* FALL THRU */ + fallthru; case 1: a = *charptr; if (a == 0x7F || a == 0xDF || a == 0xEF || a == 0xF4) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index b808a47ef5a5..653a70f3e258 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -7116,7 +7116,7 @@ set_config_option(const char *name, const char *value, return 0; } /* fall through to process the same as PGC_BACKEND */ - /* FALLTHROUGH */ + fallthru; case PGC_BACKEND: if (context == PGC_SIGHUP) { @@ -8572,7 +8572,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel) case VAR_SET_DEFAULT: if (stmt->is_local) WarnNoTransactionBlock(isTopLevel, "SET LOCAL"); - /* fall through */ + fallthru; case VAR_RESET: if (strcmp(stmt->name, "transaction_isolation") == 0 && Gp_role != GP_ROLE_EXECUTE) diff --git a/src/backend/utils/resscheduler/resscheduler.c b/src/backend/utils/resscheduler/resscheduler.c index 424cc2ef8eec..e0c89ba7c042 100644 --- a/src/backend/utils/resscheduler/resscheduler.c +++ b/src/backend/utils/resscheduler/resscheduler.c @@ -579,7 +579,7 @@ ResLockPortal(Portal portal, QueryDesc *qDesc) break; } } - /* fallthrough */ + fallthru; case T_SelectStmt: diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index c367244b0b5c..fdd6f4422482 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -1067,7 +1067,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, (errcode_for_file_access(), errmsg("could not seek in tuplestore temporary file"))); state->status = TSS_READFILE; - /* FALLTHROUGH */ + fallthru; case TSS_READFILE: *should_free = true; diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0732d1e0f56a..ec4272d692ec 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -889,7 +889,7 @@ syncTargetDirectory(void) case FILE_ACTION_CREATE: fsync_fname(entry->path, entry->source_type == FILE_TYPE_DIRECTORY); - /* FALLTHROUGH */ + fallthru; case FILE_ACTION_REMOVE: /* * Fsync the parent directory if we either create or delete diff --git a/src/common/hashfn.c b/src/common/hashfn.c index 863056b74ca4..1b8075000f68 100644 --- a/src/common/hashfn.c +++ b/src/common/hashfn.c @@ -194,13 +194,13 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -208,22 +208,22 @@ hash_bytes(const unsigned char *k, int keylen) break; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + fallthru; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + fallthru; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + fallthru; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -233,13 +233,13 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -247,22 +247,22 @@ hash_bytes(const unsigned char *k, int keylen) break; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + fallthru; case 5: b += k[4]; - /* fall through */ + fallthru; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + fallthru; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -296,35 +296,35 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += k[7]; - /* fall through */ + fallthru; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + fallthru; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + fallthru; case 4: a += k[3]; - /* fall through */ + fallthru; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + fallthru; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -334,35 +334,35 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ((uint32) k[7] << 24); - /* fall through */ + fallthru; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + fallthru; case 5: b += k[4]; - /* fall through */ + fallthru; case 4: a += ((uint32) k[3] << 24); - /* fall through */ + fallthru; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + fallthru; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -433,13 +433,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -447,22 +447,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) break; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + fallthru; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + fallthru; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + fallthru; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -472,13 +472,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -486,22 +486,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) break; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + fallthru; case 5: b += k[4]; - /* fall through */ + fallthru; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + fallthru; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -535,35 +535,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += k[7]; - /* fall through */ + fallthru; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + fallthru; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + fallthru; case 4: a += k[3]; - /* fall through */ + fallthru; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + fallthru; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -573,35 +573,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + fallthru; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + fallthru; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + fallthru; case 8: /* the lowest byte of c is reserved for the length */ b += ((uint32) k[7] << 24); - /* fall through */ + fallthru; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + fallthru; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + fallthru; case 5: b += k[4]; - /* fall through */ + fallthru; case 4: a += ((uint32) k[3] << 24); - /* fall through */ + fallthru; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + fallthru; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + fallthru; case 1: a += k[0]; /* case 0: nothing left to add */ diff --git a/src/include/c.h b/src/include/c.h index a6b4b69cdcbe..d2b40e8b8e94 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1211,6 +1211,20 @@ typedef union PGAlignedXLogBlock ((underlying_type) (expr)) #endif +#if defined __has_attribute + #if __has_attribute(fallthrough) + #define fallthru __attribute__((fallthrough)) + #else + #define fallthru do {} while (0) + #endif +#else + /* + * This is a fallback option for those compilers which don't support + * "fallthrough" attribute. If that's the case, then do nothing. + */ + #define fallthru do {} while (0) +#endif + /* ---------------------------------------------------------------- * Section 9: system-specific hacks * diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index ca0728404aac..6f90c51d4494 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -184,7 +184,7 @@ DecodeISO8601Interval(char *str, continue; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + fallthru; case '-': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -263,7 +263,7 @@ DecodeISO8601Interval(char *str, return 0; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + fallthru; case ':': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -391,7 +391,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */ tmask = DTK_M(TZ); break; } - /* FALL THROUGH */ + fallthru; case DTK_DATE: case DTK_NUMBER: diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index e6adaf635540..c5cd12ce39b1 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -190,7 +190,7 @@ main(int argc, char *const argv[]) case 'h': header_mode = true; /* this must include "-c" to make sense, so fall through */ - /* FALLTHROUGH */ + fallthru; case 'c': auto_create_c = true; break; diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index dd4db1115059..4b79ef2baea5 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -383,7 +383,7 @@ pqsecure_raw_write(PGconn *conn, const void *ptr, size_t len) REMEMBER_EPIPE(spinfo, true); #ifdef ECONNRESET - /* FALL THRU */ + fallthru; case ECONNRESET: #endif diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h index 8dc181335a88..8c893c23501a 100644 --- a/src/pl/plperl/plperl.h +++ b/src/pl/plperl/plperl.h @@ -82,7 +82,19 @@ */ #define PERL_NO_GET_CONTEXT #include "EXTERN.h" -#include "perl.h" +#if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wimplicit-fallthrough" + #include "perl.h" + #pragma clang diagnostic pop +#elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + #include "perl.h" + #pragma GCC diagnostic pop +#else + #include "perl.h" +#endif /* * We want to include XSUB.h only within .xs files, because on some platforms diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index e007f09f4370..5fe7a1147eae 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -2425,7 +2425,7 @@ plpgsql_add_initdatums(int **varnos) case PLPGSQL_DTYPE_VAR: case PLPGSQL_DTYPE_REC: (*varnos)[n++] = plpgsql_Datums[i]->dno; - + break; default: break; } diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index ad5be851a17c..964db47bd235 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3203,7 +3203,7 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) retvar); - /* FALL THRU */ + fallthru; case PLPGSQL_DTYPE_VAR: { @@ -3349,7 +3349,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) retvar); - /* FALL THRU */ + fallthru; case PLPGSQL_DTYPE_VAR: { @@ -5463,7 +5463,7 @@ exec_eval_datum(PLpgSQL_execstate *estate, /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) datum); - /* FALL THRU */ + fallthru; case PLPGSQL_DTYPE_VAR: { diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 00ebe29d61d4..de0a104c2899 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2454,7 +2454,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp, break; } /* fall through for utility returning tuples */ - /* FALLTHROUGH */ + fallthru; case SPI_OK_SELECT: case SPI_OK_INSERT_RETURNING: diff --git a/src/port/glob.c b/src/port/glob.c index 9fab8b827d64..ea79638e1cd8 100644 --- a/src/port/glob.c +++ b/src/port/glob.c @@ -333,7 +333,7 @@ globexp2(ptr, pattern, pglob, rv) i--; break; } - /* FALLTHROUGH */ + fallthru; case COMMA: if (i && *pm == COMMA) break; diff --git a/src/port/snprintf.c b/src/port/snprintf.c index df8745d4f12b..5acd931b3075 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -465,7 +465,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) /* set zero padding if no nonzero digits yet */ if (accum == 0 && !pointflag) zpad = '0'; - /* FALL THRU */ + fallthru; case '1': case '2': case '3': diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 0ea6ead2db3a..b8d9cf868867 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -1393,19 +1393,19 @@ gethms(char const *string, char const *errstring) break; case 8: ok = '0' <= xr && xr <= '9'; - /* fallthrough */ + fallthru; case 7: ok &= ssx == '.'; if (ok && noise) warning(_("fractional seconds rejected by" " pre-2018 versions of zic")); - /* fallthrough */ + fallthru; case 5: ok &= mmx == ':'; - /* fallthrough */ + fallthru; case 3: ok &= hhx == ':'; - /* fallthrough */ + fallthru; case 1: break; }