Skip to content

Commit f2ecaa1

Browse files
committed
[YSQL] Fix single-row-txn detection after primary key change
Summary: D6326 (yugabyte#955) implemented handling primary key as an index so that in can be used in an index scan path. As a side-effect it caused single-row inserts to be mis-categorized as multi-row operations causing them to use the distributed txns path (instead of the single row txn path). This fixes the relevant check. Test Plan: java -jar ./target/yb-sample-apps.jar --workload SqlInserts --nodes 127.0.0.1:5433 --num_threads_write 24 --num_threads_read 0 --num_unique_keys 1000000000 Reviewers: robert Reviewed By: robert Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D6437
1 parent 90680ca commit f2ecaa1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/postgres/src/backend/executor/nodeModifyTable.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,13 @@ ExecInsert(ModifyTableState *mtstate,
430430
bool has_triggers = resultRelInfo->ri_TrigDesc &&
431431
resultRelInfo->ri_TrigDesc->numtriggers > 0;
432432

433+
bool has_indices = resultRelInfo->ri_NumIndices > 1 ||
434+
(resultRelInfo->ri_NumIndices == 1 &&
435+
!resultRelInfo->ri_IndexRelationDescs[0]->rd_index
436+
->indisprimary);
437+
433438
bool is_single_row_txn = estate->es_yb_is_single_row_modify_txn &&
434-
resultRelInfo->ri_NumIndices == 0 &&
439+
!has_indices &&
435440
!has_triggers;
436441

437442
if (is_single_row_txn)

0 commit comments

Comments
 (0)