diff --git a/db/osqlcomm.c b/db/osqlcomm.c index 44d93ef011..e2cdb8a7b6 100644 --- a/db/osqlcomm.c +++ b/db/osqlcomm.c @@ -5977,14 +5977,16 @@ static int _process_partitioned_table_merge(struct ireq *iq) sc->kind = SC_ADDTABLE; rc = start_schema_change_tran(iq, NULL); - iq->sc->sc_next = iq->sc_pending; - iq->sc_pending = iq->sc; + if (rc != SC_COMMIT_PENDING) { if (rc != SC_MASTER_DOWNGRADE) iq->osql_flags |= OSQL_FLAGS_SCDONE; return ERR_SC; } + arg.indx = -1; /* see timepart_foreach_shardname NOTE */ + iq->sc->sc_next = iq->sc_pending; + iq->sc_pending = iq->sc; } else { /* * use the fast shard as the destination, after first altering it @@ -5995,13 +5997,15 @@ static int _process_partitioned_table_merge(struct ireq *iq) strncpy(sc->tablename, first_shard->tablename, sizeof(sc->tablename)); rc = start_schema_change_tran(iq, NULL); - iq->sc->sc_next = iq->sc_pending; - iq->sc_pending = iq->sc; if (rc != SC_COMMIT_PENDING) { if (rc != SC_MASTER_DOWNGRADE) iq->osql_flags |= OSQL_FLAGS_SCDONE; return ERR_SC; } + + iq->sc->sc_next = iq->sc_pending; + iq->sc_pending = iq->sc; + arg.check_extra_shard = 1; strncpy(sc->newtable, sc->tablename, sizeof(sc->newtable)); /* piggyback a rename with alter */ arg.indx = 0; /* see timepart_foreach_shardname NOTE */ diff --git a/tests/timepart_trunc.test/runit b/tests/timepart_trunc.test/runit index bf1ec94b13..18c212cba3 100755 --- a/tests/timepart_trunc.test/runit +++ b/tests/timepart_trunc.test/runit @@ -419,13 +419,26 @@ $cmd "select * from t14 order by 1" >> $OUT timepart_stats 0 -echo $cmd "ALTER TABLE t14 PARTITIONED BY NONE" -$cmd "ALTER TABLE t14 PARTITIONED BY NONE" -if (( $? != 0 )) ; then - echo "FAILURE to remote partitioning for t14" +$cmdm "exec procedure sys.cmd.send('convert_record_sleep 1')" + +echo $cmd "ALTER TABLE t14 PARTITIONED BY NONE &" +$cmd "ALTER TABLE t14 PARTITIONED BY NONE" & +waitpid=$! + +sleep 1 + +if $cmd "ALTER TABLE t14 PARTITIONED BY NONE"; then + echo "FAILURE to block concurrent schema change" exit 1 fi +if ! wait $waitpid; then + echo "FAILURE to remove partitioning for t14" + exit 1 +fi + +$cmdm "exec procedure sys.cmd.send('convert_record_sleep 0')" + echo $cmd "select * from t14 order by 1" echo $cmd "select * from t14 order by 1" >> $OUT $cmd "select * from t14 order by 1" >> $OUT