mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 08:03:04 +01:00
Changes in IUtl, suggested by Adriano & Dmitry
This commit is contained in:
parent
078827c8e0
commit
00971c3941
@ -46,21 +46,19 @@ class ITransaction;
|
||||
class IUtl : public IVersioned
|
||||
{
|
||||
public:
|
||||
virtual void FB_CARG version(IStatus* status, IAttachment* att,
|
||||
virtual void FB_CARG getVersion(IStatus* status, IAttachment* att,
|
||||
IVersionCallback* callback) = 0;
|
||||
virtual void FB_CARG loadBlob(IStatus* status, ISC_QUAD* blobId,
|
||||
IAttachment* att, ITransaction* tra, const char* file, FB_BOOLEAN txt) = 0;
|
||||
virtual void FB_CARG dumpBlob(IStatus* status, ISC_QUAD* blobId,
|
||||
IAttachment* att, ITransaction* tra, const char* file, FB_BOOLEAN txt) = 0;
|
||||
virtual FB_BOOLEAN FB_CARG editBlob(IStatus* status, ISC_QUAD* blobId,
|
||||
IAttachment* att, ITransaction* tra, const char* tempFile = NULL) = 0;
|
||||
virtual void FB_CARG getPerfCounters(IStatus* status, IAttachment* att,
|
||||
const char* countersSet, ISC_INT64* counters) = 0;
|
||||
virtual IAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status,
|
||||
unsigned stmtLength, const char* creatDBstatement, unsigned dialect,
|
||||
FB_BOOLEAN* stmtIsCreateDb = NULL) = 0;
|
||||
};
|
||||
#define FB_UTL_VERSION (FB_VERSIONED_VERSION + 6)
|
||||
#define FB_UTL_VERSION (FB_VERSIONED_VERSION + 5)
|
||||
|
||||
} // namespace Firebird
|
||||
|
||||
|
@ -2399,7 +2399,21 @@ static processing_state blobedit(const TEXT* action, const TEXT* const* cmd)
|
||||
|
||||
processing_state rc = SKIP;
|
||||
if (!strcmp(action, "BLOBVIEW"))
|
||||
Firebird::UtlInterfacePtr()->editBlob(fbStatus, &blobid, DB, M__trans, "blob");
|
||||
{
|
||||
Firebird::UtlInterfacePtr utl;
|
||||
PathName tmpf = TempFile::create(fbStatus, "blob");
|
||||
if (ISQL_errmsg(fbStatus))
|
||||
return ps_ERR;
|
||||
const char* filename = tmpf.c_str();
|
||||
|
||||
utl->dumpBlob(fbStatus, &blobid, DB, M__trans, filename, FB_TRUE);
|
||||
if (ISQL_errmsg(fbStatus))
|
||||
rc = ps_ERR;
|
||||
else
|
||||
gds__edit(filename, 0);
|
||||
|
||||
unlink(filename);
|
||||
}
|
||||
else if ((!strcmp(action, "BLOBDUMP")) && (*cmd[2]))
|
||||
{
|
||||
// If this is a blobdump, make sure there is a file name
|
||||
|
@ -1567,7 +1567,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd, SCHAR** lcmd)
|
||||
isqlGlob.printf("%s%s", msg_string, NEWLINE);
|
||||
isqlGlob.printf("Server version:%s", NEWLINE);
|
||||
VersionCallback callback;
|
||||
Firebird::UtlInterfacePtr()->version(fbStatus, DB, &callback);
|
||||
Firebird::UtlInterfacePtr()->getVersion(fbStatus, DB, &callback);
|
||||
if (!fbStatus->isSuccess())
|
||||
{
|
||||
IUTILS_msg_get(CANNOT_GET_SRV_VER, msg_string);
|
||||
|
@ -358,26 +358,6 @@ namespace Why {
|
||||
|
||||
UtlInterface utlInterface;
|
||||
|
||||
FB_BOOLEAN FB_CARG UtlInterface::editBlob(Firebird::IStatus* status, ISC_QUAD* blobId,
|
||||
Firebird::IAttachment* att, Firebird::ITransaction* tra, const char* tempFile)
|
||||
{
|
||||
FB_BOOLEAN rc = FB_FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
rc = edit(status, blobId, att, tra, TRUE, tempFile);
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuffException(status);
|
||||
}
|
||||
|
||||
if (!status->isSuccess() && status->get()[1] != isc_segstr_eof)
|
||||
isc_print_status(status->get());
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FB_CARG UtlInterface::dumpBlob(IStatus* status, ISC_QUAD* blobId,
|
||||
IAttachment* att, ITransaction* tra, const char* file_name, FB_BOOLEAN txt)
|
||||
{
|
||||
@ -428,7 +408,7 @@ void FB_CARG UtlInterface::loadBlob(IStatus* status, ISC_QUAD* blobId,
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void UtlInterface::version(IStatus* status, IAttachment* att,
|
||||
void UtlInterface::getVersion(IStatus* status, IAttachment* att,
|
||||
IVersionCallback* callback)
|
||||
{
|
||||
/**************************************
|
||||
@ -1481,7 +1461,7 @@ int API_ROUTINE isc_version(FB_API_HANDLE* handle, FPTR_VERSION_CALLBACK routine
|
||||
return FB_FAILURE;
|
||||
|
||||
VersionCallback callback(routine, user_arg);
|
||||
UtlInterfacePtr()->version(&st, att, &callback);
|
||||
UtlInterfacePtr()->getVersion(&st, att, &callback);
|
||||
|
||||
return st.isSuccess() ? FB_SUCCESS : FB_FAILURE;
|
||||
}
|
||||
@ -1820,7 +1800,17 @@ int API_ROUTINE BLOB_edit(ISC_QUAD* blob_id,
|
||||
if (!st.isSuccess())
|
||||
return FB_FAILURE;
|
||||
|
||||
int rc = UtlInterfacePtr()->editBlob(&st, blob_id, att, tra, field_name);
|
||||
int rc = FB_SUCCESS;
|
||||
|
||||
try
|
||||
{
|
||||
rc = edit(&st, blob_id, att, tra, TRUE, field_name) ? FB_SUCCESS : FB_FAILURE;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuffException(&st);
|
||||
}
|
||||
|
||||
if (!st.isSuccess() && st.get()[1] != isc_segstr_eof)
|
||||
isc_print_status(st.get());
|
||||
|
||||
|
@ -89,14 +89,12 @@ class UtlInterface : public Firebird::AutoIface<Firebird::IUtl, FB_UTL_VERSION>
|
||||
{
|
||||
// IUtl implementation
|
||||
public:
|
||||
void FB_CARG version(Firebird::IStatus* status, Firebird::IAttachment* att,
|
||||
void FB_CARG getVersion(Firebird::IStatus* status, Firebird::IAttachment* att,
|
||||
Firebird::IVersionCallback* callback);
|
||||
void FB_CARG loadBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att,
|
||||
Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt);
|
||||
void FB_CARG dumpBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att,
|
||||
Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt);
|
||||
FB_BOOLEAN FB_CARG editBlob(Firebird::IStatus* status, ISC_QUAD* blobId,
|
||||
Firebird::IAttachment* att, Firebird::ITransaction* tra, const char* tempFile = NULL);
|
||||
void FB_CARG getPerfCounters(Firebird::IStatus* status, Firebird::IAttachment* att,
|
||||
const char* countersSet, ISC_INT64* counters); // in perf.cpp
|
||||
virtual YAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status,
|
||||
|
Loading…
Reference in New Issue
Block a user