@@ -1459,6 +1459,51 @@ BOOST_AUTO_TEST_CASE(cursorMethodsReturnFalseWithoutResultSet)
14591459 BOOST_CHECK_EQUAL (insert.fetchRelative (1 ), false );
14601460}
14611461
1462+ BOOST_AUTO_TEST_CASE (cursorName)
1463+ {
1464+ const auto database = getTempFile (" Statement-cursorName.fdb" );
1465+
1466+ Attachment attachment{CLIENT , database, AttachmentOptions ().setCreateDatabase (true )};
1467+ FbDropDatabase attachmentDrop{attachment};
1468+
1469+ Transaction transaction{attachment};
1470+
1471+ Statement ddl{attachment, transaction, " create table t (col integer)" };
1472+ ddl.execute (transaction);
1473+ transaction.commitRetaining ();
1474+
1475+ Statement insert{attachment, transaction, " insert into t (col) values (?)" };
1476+ for (int i = 1 ; i <= 3 ; ++i)
1477+ {
1478+ insert.setInt32 (0 , i);
1479+ insert.execute (transaction);
1480+ }
1481+
1482+ Statement select{
1483+ attachment, transaction, " select col from t order by col for update" , StatementOptions ().setCursorName (" c" )};
1484+ BOOST_REQUIRE (select.execute (transaction));
1485+
1486+ BOOST_CHECK_EQUAL (select.getInt32 (0 ).value (), 1 );
1487+
1488+ Statement updateStmt{attachment, transaction, " update t set col = col + 10 where current of c returning col" };
1489+ BOOST_REQUIRE (updateStmt.execute (transaction));
1490+ BOOST_CHECK_EQUAL (updateStmt.getInt32 (0 ).value (), 11 );
1491+
1492+ BOOST_CHECK (select.fetchNext ());
1493+ BOOST_CHECK_EQUAL (select.getInt32 (0 ).value (), 2 );
1494+
1495+ Statement deleteStmt{attachment, transaction, " delete from t where current of c returning col" };
1496+ BOOST_REQUIRE (deleteStmt.execute (transaction));
1497+ BOOST_CHECK_EQUAL (deleteStmt.getInt32 (0 ).value (), 2 );
1498+
1499+ Statement verify{attachment, transaction, " select col from t order by col" };
1500+ BOOST_REQUIRE (verify.execute (transaction));
1501+ BOOST_CHECK_EQUAL (verify.getInt32 (0 ).value (), 3 );
1502+ BOOST_CHECK (verify.fetchNext ());
1503+ BOOST_CHECK_EQUAL (verify.getInt32 (0 ).value (), 11 );
1504+ BOOST_CHECK (!verify.fetchNext ());
1505+ }
1506+
14621507BOOST_AUTO_TEST_SUITE_END ()
14631508
14641509
0 commit comments