MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / PAG_set_db_readonly

Function PAG_set_db_readonly

src/jrd/pag.cpp:1771–1823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1769
1770
1771void PAG_set_db_readonly(thread_db* tdbb, bool flag)
1772{
1773/*********************************************
1774 *
1775 * P A G _ s e t _ d b _ r e a d o n l y
1776 *
1777 *********************************************
1778 *
1779 * Functional description
1780 * Set database access mode to readonly OR readwrite
1781 *
1782 *********************************************/
1783 SET_TDBB(tdbb);
1784 Database* dbb = tdbb->getDatabase();
1785
1786 WIN window(HEADER_PAGE_NUMBER);
1787 header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
1788
1789 if (!flag)
1790 {
1791 // If the database is transitioning from RO to RW, reset the
1792 // in-memory Database flag which indicates that the database is RO.
1793 // This will allow the CCH subsystem to allow pages to be MARK'ed
1794 // for WRITE operations
1795 header->hdr_flags &= ~hdr_read_only;
1796 dbb->dbb_flags &= ~DBB_read_only;
1797
1798 // Take into account current attachment ID, else next attachment
1799 // (cache writer, for examle) will get the same att ID and wait
1800 // for att lock indefinitely.
1801 Attachment* att = tdbb->getAttachment();
1802 if (att->att_attachment_id)
1803 Ods::writeAttID(header, att->att_attachment_id);
1804
1805 // This is necessary as dbb's Next could be less than OAT.
1806 // And this is safe as we currently in exclusive attachment and
1807 // all executed transactions was read-only.
1808 dbb->dbb_next_transaction = Ods::getNT(header);
1809 dbb->dbb_oldest_transaction = Ods::getOIT(header);
1810 dbb->dbb_oldest_active = Ods::getOAT(header);
1811 dbb->dbb_oldest_snapshot = Ods::getOST(header);
1812 }
1813
1814 CCH_MARK_MUST_WRITE(tdbb, &window);
1815
1816 if (flag)
1817 {
1818 header->hdr_flags |= hdr_read_only;
1819 dbb->dbb_flags |= DBB_read_only;
1820 }
1821
1822 CCH_RELEASE(tdbb, &window);
1823}
1824
1825
1826void PAG_set_db_replica(thread_db* tdbb, ReplicaMode mode)

Callers 2

internalAttachMethod · 0.85
createDatabaseMethod · 0.85

Calls 11

SET_TDBBFunction · 0.85
CCH_FETCHFunction · 0.85
writeAttIDFunction · 0.85
getNTFunction · 0.85
getOITFunction · 0.85
getOATFunction · 0.85
getOSTFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
CCH_RELEASEFunction · 0.85
getDatabaseMethod · 0.80
getAttachmentMethod · 0.45

Tested by

no test coverage detected