8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00

Changes in IUtl, suggested by Adriano & Dmitry

This commit is contained in:
alexpeshkoff 2014-01-20 14:36:08 +00:00
parent 078827c8e0
commit 00971c3941
5 changed files with 32 additions and 32 deletions

View File

@ -46,21 +46,19 @@ class ITransaction;
class IUtl : public IVersioned class IUtl : public IVersioned
{ {
public: public:
virtual void FB_CARG version(IStatus* status, IAttachment* att, virtual void FB_CARG getVersion(IStatus* status, IAttachment* att,
IVersionCallback* callback) = 0; IVersionCallback* callback) = 0;
virtual void FB_CARG loadBlob(IStatus* status, ISC_QUAD* blobId, virtual void FB_CARG loadBlob(IStatus* status, ISC_QUAD* blobId,
IAttachment* att, ITransaction* tra, const char* file, FB_BOOLEAN txt) = 0; IAttachment* att, ITransaction* tra, const char* file, FB_BOOLEAN txt) = 0;
virtual void FB_CARG dumpBlob(IStatus* status, ISC_QUAD* blobId, virtual void FB_CARG dumpBlob(IStatus* status, ISC_QUAD* blobId,
IAttachment* att, ITransaction* tra, const char* file, FB_BOOLEAN txt) = 0; 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, virtual void FB_CARG getPerfCounters(IStatus* status, IAttachment* att,
const char* countersSet, ISC_INT64* counters) = 0; const char* countersSet, ISC_INT64* counters) = 0;
virtual IAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status, virtual IAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status,
unsigned stmtLength, const char* creatDBstatement, unsigned dialect, unsigned stmtLength, const char* creatDBstatement, unsigned dialect,
FB_BOOLEAN* stmtIsCreateDb = NULL) = 0; FB_BOOLEAN* stmtIsCreateDb = NULL) = 0;
}; };
#define FB_UTL_VERSION (FB_VERSIONED_VERSION + 6) #define FB_UTL_VERSION (FB_VERSIONED_VERSION + 5)
} // namespace Firebird } // namespace Firebird

View File

@ -2399,7 +2399,21 @@ static processing_state blobedit(const TEXT* action, const TEXT* const* cmd)
processing_state rc = SKIP; processing_state rc = SKIP;
if (!strcmp(action, "BLOBVIEW")) 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])) else if ((!strcmp(action, "BLOBDUMP")) && (*cmd[2]))
{ {
// If this is a blobdump, make sure there is a file name // If this is a blobdump, make sure there is a file name

View File

@ -1567,7 +1567,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd, SCHAR** lcmd)
isqlGlob.printf("%s%s", msg_string, NEWLINE); isqlGlob.printf("%s%s", msg_string, NEWLINE);
isqlGlob.printf("Server version:%s", NEWLINE); isqlGlob.printf("Server version:%s", NEWLINE);
VersionCallback callback; VersionCallback callback;
Firebird::UtlInterfacePtr()->version(fbStatus, DB, &callback); Firebird::UtlInterfacePtr()->getVersion(fbStatus, DB, &callback);
if (!fbStatus->isSuccess()) if (!fbStatus->isSuccess())
{ {
IUTILS_msg_get(CANNOT_GET_SRV_VER, msg_string); IUTILS_msg_get(CANNOT_GET_SRV_VER, msg_string);

View File

@ -358,26 +358,6 @@ namespace Why {
UtlInterface utlInterface; 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, void FB_CARG UtlInterface::dumpBlob(IStatus* status, ISC_QUAD* blobId,
IAttachment* att, ITransaction* tra, const char* file_name, FB_BOOLEAN txt) 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); fclose(file);
} }
void UtlInterface::version(IStatus* status, IAttachment* att, void UtlInterface::getVersion(IStatus* status, IAttachment* att,
IVersionCallback* callback) IVersionCallback* callback)
{ {
/************************************** /**************************************
@ -1481,7 +1461,7 @@ int API_ROUTINE isc_version(FB_API_HANDLE* handle, FPTR_VERSION_CALLBACK routine
return FB_FAILURE; return FB_FAILURE;
VersionCallback callback(routine, user_arg); VersionCallback callback(routine, user_arg);
UtlInterfacePtr()->version(&st, att, &callback); UtlInterfacePtr()->getVersion(&st, att, &callback);
return st.isSuccess() ? FB_SUCCESS : FB_FAILURE; return st.isSuccess() ? FB_SUCCESS : FB_FAILURE;
} }
@ -1820,7 +1800,17 @@ int API_ROUTINE BLOB_edit(ISC_QUAD* blob_id,
if (!st.isSuccess()) if (!st.isSuccess())
return FB_FAILURE; 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) if (!st.isSuccess() && st.get()[1] != isc_segstr_eof)
isc_print_status(st.get()); isc_print_status(st.get());

View File

@ -89,14 +89,12 @@ class UtlInterface : public Firebird::AutoIface<Firebird::IUtl, FB_UTL_VERSION>
{ {
// IUtl implementation // IUtl implementation
public: public:
void FB_CARG version(Firebird::IStatus* status, Firebird::IAttachment* att, void FB_CARG getVersion(Firebird::IStatus* status, Firebird::IAttachment* att,
Firebird::IVersionCallback* callback); Firebird::IVersionCallback* callback);
void FB_CARG loadBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att, void FB_CARG loadBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att,
Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt); Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt);
void FB_CARG dumpBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att, void FB_CARG dumpBlob(Firebird::IStatus* status, ISC_QUAD* blobId, Firebird::IAttachment* att,
Firebird::ITransaction* tra, const char* file, FB_BOOLEAN txt); 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, void FB_CARG getPerfCounters(Firebird::IStatus* status, Firebird::IAttachment* att,
const char* countersSet, ISC_INT64* counters); // in perf.cpp const char* countersSet, ISC_INT64* counters); // in perf.cpp
virtual YAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status, virtual YAttachment* FB_CARG executeCreateDatabase(Firebird::IStatus* status,