Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't simplify uncorrelated EXISTS sublink in some cases #823

Merged
merged 13 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -6693,7 +6693,8 @@ fi
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
fi
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
# of warnings when building plperl because of usages in the Perl headers.
# of warnings when building plperl because of Perl. Like previously, test
# for the positive form and add the negative form
NOT_THE_CFLAGS=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ if test "$GCC" = yes -a "$ICC" = no; then
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
fi
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
# of warnings when building plperl because of usages in the Perl headers.
# of warnings when building plperl because of Perl. Like previously, test
# for the positive form and add the negative form
NOT_THE_CFLAGS=""
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
if test -n "$NOT_THE_CFLAGS"; then
Expand Down
56 changes: 49 additions & 7 deletions src/backend/access/aocs/aocsam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,20 +1058,29 @@ aoco_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
pgstat_count_heap_insert(relation, 1);
}

/*
* We don't support speculative inserts on appendoptimized tables, i.e. we don't
* support INSERT ON CONFLICT DO NOTHING or INSERT ON CONFLICT DO UPDATE. Thus,
* the following functions are left unimplemented.
*/

static void
aoco_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
CommandId cid, int options,
BulkInsertState bistate, uint32 specToken)
{
/* GPDB_12_MERGE_FIXME: not supported. Can this function be left out completely? Or ereport()? */
elog(ERROR, "speculative insertion not supported on AO_COLUMN tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("speculative insert is not supported on appendoptimized relations")));
}

static void
aoco_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
uint32 specToken, bool succeeded)
{
elog(ERROR, "speculative insertion not supported on AO_COLUMN tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("speculative insert is not supported on appendoptimized relations")));
}

/*
Expand Down Expand Up @@ -1175,14 +1184,38 @@ aoco_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
return result;
}

/*
* This API is called for a variety of purposes, which are either not supported
* for AO/CO tables or not supported for GPDB in general:
*
* (1) UPSERT: ExecOnConflictUpdate() calls this, but clearly upsert is not
* supported for AO/CO tables.
*
* (2) DELETE and UPDATE triggers: GetTupleForTrigger() calls this, but clearly
* these trigger types are not supported for AO/CO tables.
*
* (3) Logical replication: RelationFindReplTupleByIndex() and
* RelationFindReplTupleSeq() calls this, but clearly we don't support logical
* replication yet for GPDB.
*
* (4) For DELETEs/UPDATEs, when a state of TM_Updated is returned from
* table_tuple_delete() and table_tuple_update() respectively, this API is invoked.
* However, that is impossible for AO/CO tables as an AO/CO tuple cannot be
* deleted/updated while another transaction is updating it (see CdbTryOpenTable()).
*
* (5) Row-level locking (SELECT FOR ..): ExecLockRows() calls this but a plan
* containing the LockRows plan node is never generated for AO/CO tables. In fact,
* we lock at the table level instead.
*/
static TM_Result
aoco_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
LockWaitPolicy wait_policy, uint8 flags,
TM_FailureData *tmfd)
{
/* GPDB_12_MERGE_FIXME: not supported. Can this function be left out completely? Or ereport()? */
elog(ERROR, "speculative insertion not supported on AO tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("tuple locking is not supported on appendoptimized tables")));
}

static void
Expand Down Expand Up @@ -1269,8 +1302,17 @@ static TransactionId
aoco_index_delete_tuples(Relation rel,
TM_IndexDeleteOp *delstate)
{
// GPDB_14_MERGE_FIXME: vacuum related call back.
elog(ERROR, "not implemented yet");
/*
* This API is only useful for hot standby snapshot conflict resolution
* (for eg. see btree_xlog_delete()), in the context of index page-level
* vacuums (aka page-level cleanups). This operation is only done when
* IndexScanDesc->kill_prior_tuple is true, which is never for AO/CO tables
* (we always return all_dead = false in the index_fetch_tuple() callback
* as we don't support HOT)
*/
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("feature not supported on appendoptimized relations")));
}


Expand Down
56 changes: 49 additions & 7 deletions src/backend/access/appendonly/appendonlyam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,17 @@ static TransactionId
appendonly_index_delete_tuples(Relation rel,
TM_IndexDeleteOp *delstate)
{
// GPDB_14_MERGE_FIXME: vacuum related call back.
elog(ERROR, "not implemented yet");
/*
* This API is only useful for hot standby snapshot conflict resolution
* (for eg. see btree_xlog_delete()), in the context of index page-level
* vacuums (aka page-level cleanups). This operation is only done when
* IndexScanDesc->kill_prior_tuple is true, which is never for AO/CO tables
* (we always return all_dead = false in the index_fetch_tuple() callback
* as we don't support HOT)
*/
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("feature not supported on appendoptimized relations")));
}


Expand Down Expand Up @@ -919,20 +928,29 @@ appendonly_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
appendonly_free_memtuple(mtuple);
}

/*
* We don't support speculative inserts on appendoptimized tables, i.e. we don't
* support INSERT ON CONFLICT DO NOTHING or INSERT ON CONFLICT DO UPDATE. Thus,
* the following functions are left unimplemented.
*/

static void
appendonly_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
CommandId cid, int options,
BulkInsertState bistate, uint32 specToken)
{
/* GPDB_12_MERGE_FIXME: not supported. Can this function be left out completely? Or ereport()? */
elog(ERROR, "speculative insertion not supported on AO tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("speculative insert is not supported on appendoptimized relations")));
}

static void
appendonly_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
uint32 specToken, bool succeeded)
{
elog(ERROR, "speculative insertion not supported on AO tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("speculative insert is not supported on appendoptimized relations")));
}

/*
Expand Down Expand Up @@ -1122,14 +1140,38 @@ appendonly_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slo
return result;
}

/*
* This API is called for a variety of purposes, which are either not supported
* for AO/CO tables or not supported for GPDB in general:
*
* (1) UPSERT: ExecOnConflictUpdate() calls this, but clearly upsert is not
* supported for AO/CO tables.
*
* (2) DELETE and UPDATE triggers: GetTupleForTrigger() calls this, but clearly
* these trigger types are not supported for AO/CO tables.
*
* (3) Logical replication: RelationFindReplTupleByIndex() and
* RelationFindReplTupleSeq() calls this, but clearly we don't support logical
* replication yet for GPDB.
*
* (4) For DELETEs/UPDATEs, when a state of TM_Updated is returned from
* table_tuple_delete() and table_tuple_update() respectively, this API is invoked.
* However, that is impossible for AO/CO tables as an AO/CO tuple cannot be
* deleted/updated while another transaction is updating it (see CdbTryOpenTable()).
*
* (5) Row-level locking (SELECT FOR ..): ExecLockRows() calls this but a plan
* containing the LockRows plan node is never generated for AO/CO tables. In fact,
* we lock at the table level instead.
*/
static TM_Result
appendonly_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
LockWaitPolicy wait_policy, uint8 flags,
TM_FailureData *tmfd)
{
/* GPDB_12_MERGE_FIXME: not supported. Can this function be left out completely? Or ereport()? */
elog(ERROR, "speculative insertion not supported on AO tables");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("tuple locking is not supported on appendoptimized tables")));
}

static void
Expand Down
6 changes: 1 addition & 5 deletions src/backend/cdb/cdbgroupingpaths.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ cdb_create_multistage_grouping_paths(PlannerInfo *root,
/*
* Is the input hashable / sortable? This is largely the same logic as in
* upstream create_grouping_paths(), but we can do hashing in limited ways
* even if there are DISTINCT aggs or grouping setst.
*
* GPDB_12_MERGE:FIXME: the similar rules in planner.c got more complicated.
* Does this need to be more fine-grained too? See GROUPING_CAN_USE_SORT and
* GROUPING_CAN_USE_HASH.
* even if there are DISTINCT aggs or grouping sets.
*/
can_sort = grouping_is_sortable(parse->groupClause);
can_hash = (parse->groupClause != NIL &&
Expand Down
6 changes: 6 additions & 0 deletions src/backend/parser/analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
icolumns = checkInsertTargets(pstate, stmt->cols, &attrnos);
Assert(list_length(icolumns) == list_length(attrnos));

/* GPDB: We don't support speculative insert for AO/CO tables yet */
if (RelationIsAppendOptimized(pstate->p_target_relation) && stmt->onConflictClause)
ereport(ERROR,
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("INSERT ON CONFLICT is not supported for appendoptimized relations"));

/*
* Determine which variant of INSERT we have.
*/
Expand Down
12 changes: 0 additions & 12 deletions src/backend/parser/parse_cte.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,19 +1137,7 @@ checkWellFormedRecursionWalker(Node *node, CteState *cstate)
checkWellFormedRecursionWalker(sl->testexpr, cstate);
return false;
}
if (IsA(node, RangeSubselect))
{
RangeSubselect *rs = (RangeSubselect *) node;

/*
* we intentionally override outer context, since subquery is
* independent
*/
cstate->context = RECURSION_SUBLINK;
checkWellFormedRecursionWalker(rs->subquery, cstate);
cstate->context = save_context;
return false;
}
return raw_expression_tree_walker(node,
checkWellFormedRecursionWalker,
(void *) cstate);
Expand Down
13 changes: 0 additions & 13 deletions src/backend/utils/time/snapmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2842,16 +2842,3 @@ XidInMVCCSnapshot_Local(TransactionId xid, Snapshot snapshot)

return false;
}

DistributedSnapshotWithLocalMapping *
GetCurrentDistributedSnapshotWithLocalMapping()
{
if (!FirstSnapshotSet)
return NULL;

Assert(CurrentSnapshot);
if (CurrentSnapshot->haveDistribSnapshot)
return &CurrentSnapshot->distribSnapshotWithLocalMapping;

return NULL;
}
1 change: 0 additions & 1 deletion src/include/utils/snapmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ extern void AtSubAbort_Snapshot(int level);
extern void AtEOXact_Snapshot(bool isCommit, bool resetXmin);

extern void LogDistributedSnapshotInfo(Snapshot snapshot, const char *prefix);
extern DistributedSnapshotWithLocalMapping *GetCurrentDistributedSnapshotWithLocalMapping(void);

extern void ImportSnapshot(const char *idstr);
extern bool XactHasExportedSnapshots(void);
Expand Down
6 changes: 5 additions & 1 deletion src/test/isolation2/sql_isolation_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ def process_command(self, command, output_file, global_sh_executor):
pass
elif flag == "M":
self.get_process(output_file, process_name, con_mode, dbname=dbname).query(sql.strip(), post_run_cmd, global_sh_executor)
elif flag == "Mq":
if len(sql) > 0:
raise Exception("No query should be given on quit Mq")
self.quit_process(output_file, process_name, con_mode, dbname=dbname)
else:
raise Exception("Invalid isolation flag")

Expand All @@ -812,7 +816,7 @@ def process_isolation_file(self, sql_file, output_file, initfile_prefix):
if command_part == "" or command_part == "\n":
print(file=output_file)
newline = True
elif re.match(r".*;\s*$", command_part) or re.match(r"^\d+[q\\<]:\s*$", line) or re.match(r"^\*Rq:$", line) or re.match(r"^-?\d+[SUR][q\\<]:\s*$", line):
elif re.match(r".*;\s*$", command_part) or re.match(r"^\d+[q\\<]:\s*$", line) or re.match(r"^\*Rq:$", line) or re.match(r"^-?\d+[SUMR][q\\<]:\s*$", line):
command += command_part
try:
self.process_command(command, output_file, shell_executor)
Expand Down
9 changes: 2 additions & 7 deletions src/test/regress/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# Configure-generated files
/GPTest.pm


# ignore test tablespaces
/testtablespace_default_tablespace/
/testtablespace_temp_tablespace/

twophase_pqexecparams

data/part_ext.tbl
data/wet_csv?.tbl
data/wet_text?.tbl
data/wet_syntax?.tbl
Expand All @@ -25,12 +25,7 @@ data/gpsd-without-hll.sql
data/gpsd-with-hll.sql
data/minirepro.sql

regression.diffs
regression.out

stdin
stdout
# Note: regression.* are only left behind on a failure; that's why they're not ignored
# Note: regreesion.* are only left behind on a failure; that's why they're not ignored
#/regression.diffs
#/regression.out

Expand Down
Loading
Loading