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

Method createBlob

src/remote/client/interface.cpp:1815–1889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813
1814
1815IBlob* Attachment::createBlob(CheckStatusWrapper* status, ITransaction* apiTra, ISC_QUAD* blob_id,
1816 unsigned int bpb_length, const unsigned char* bpb)
1817{
1818/**************************************
1819 *
1820 * g d s _ c r e a t e _ b l o b 2
1821 *
1822 **************************************
1823 *
1824 * Functional description
1825 * Open an existing blob.
1826 *
1827 **************************************/
1828 try
1829 {
1830 reset(status);
1831
1832 CHECK_HANDLE(rdb, isc_bad_db_handle);
1833 rem_port* port = rdb->rdb_port;
1834 RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION);
1835
1836 Rtr* transaction = remoteTransaction(apiTra);
1837 CHECK_HANDLE(transaction, isc_bad_trans_handle);
1838
1839 // Validate data length
1840
1841 CHECK_LENGTH(port, bpb_length);
1842
1843 PACKET* packet = &rdb->rdb_packet;
1844 packet->p_operation = op_create_blob2;
1845 P_BLOB* p_blob = &packet->p_blob;
1846 p_blob->p_blob_transaction = transaction->rtr_id;
1847 p_blob->p_blob_bpb.cstr_length = bpb_length;
1848 fb_assert(!p_blob->p_blob_bpb.cstr_allocated ||
1849 p_blob->p_blob_bpb.cstr_allocated < p_blob->p_blob_bpb.cstr_length);
1850 // CVC: Should we ensure here that cstr_allocated < bpb_length???
1851 // Otherwise, xdr_cstring() calling alloc_string() to decode would
1852 // cause memory problems on the client side for SS, as the client
1853 // would try to write to the application's provided R/O buffer.
1854 p_blob->p_blob_bpb.cstr_address = bpb;
1855
1856 try
1857 {
1858 send_and_receive(status, rdb, packet);
1859 }
1860 catch (const Exception&)
1861 {
1862 p_blob->p_blob_bpb.cstr_length = 0;
1863 p_blob->p_blob_bpb.cstr_address = NULL;
1864
1865 throw;
1866 }
1867
1868 p_blob->p_blob_bpb.cstr_length = 0;
1869 p_blob->p_blob_bpb.cstr_address = NULL;
1870
1871 Rbl* blob = FB_NEW Rbl(BLOB_LENGTH);
1872 blob->rbl_blob_id = *blob_id = packet->p_resp.p_resp_blob_id;

Callers 1

open_blobMethod · 0.45

Calls 9

CHECK_HANDLEFunction · 0.85
CHECK_LENGTHFunction · 0.85
send_and_receiveFunction · 0.85
RblClass · 0.85
resetFunction · 0.70
BlobClass · 0.70
addMethod · 0.45
addRefMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected