|
From: <ale...@us...> - 2013-02-21 14:59:28
|
Revision: 57684
http://sourceforge.net/p/firebird/code/57684
Author: alexpeshkoff
Date: 2013-02-21 14:59:24 +0000 (Thu, 21 Feb 2013)
Log Message:
-----------
Enhancements of IMetadataBuilder
Modified Paths:
--------------
firebird/trunk/examples/interfaces/select.cpp
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/common/MsgMetadata.cpp
firebird/trunk/src/common/MsgMetadata.h
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/examples/interfaces/select.cpp
===================================================================
--- firebird/trunk/examples/interfaces/select.cpp 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/examples/interfaces/select.cpp 2013-02-21 14:59:24 UTC (rev 57684)
@@ -59,7 +59,7 @@
IStatement* stmt = NULL;
IResultSet* curs = NULL;
IMessageMetadata* meta = NULL;
- ICoerceMetadata* coerce = NULL;
+ IMetadataBuilder* builder = NULL;
try
{
@@ -83,8 +83,8 @@
// get list of columns
meta = stmt->getOutputMetadata(st);
check(st, "getOutputMetadata");
- coerce = meta->coerce(st);
- check(st, "coerce");
+ builder = meta->getBuilder(st);
+ check(st, "getBuilder");
unsigned cols = meta->getCount(st);
check(st, "getCount");
@@ -105,7 +105,7 @@
if (t == SQL_VARYING || t == SQL_TEXT)
{
- coerce->setType(st, j, SQL_TEXT);
+ builder->setType(st, j, SQL_TEXT);
check(st, "setType");
fields[j].name = meta->getField(st, j);
check(st, "getField");
@@ -113,7 +113,7 @@
}
meta->release();
- meta = coerce->getMetadata(st);
+ meta = builder->getMetadata(st);
check(st, "getMetadata");
// now we may also get offsets info
@@ -128,8 +128,8 @@
}
}
- coerce->release();
- coerce = NULL;
+ builder->release();
+ builder = NULL;
// open cursor
curs = stmt->openCursor(st, tra, NULL, meta);
@@ -187,8 +187,8 @@
// release interfaces after error caught
if (meta)
meta->release();
- if (coerce)
- coerce->release();
+ if (builder)
+ builder->release();
if (curs)
curs->release();
if (stmt)
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2013-02-21 14:59:24 UTC (rev 57684)
@@ -1514,6 +1514,8 @@
PARAMETER (GDS__wrong_message_length = 335545050)
INTEGER*4 GDS__no_output_format
PARAMETER (GDS__no_output_format = 335545051)
+ INTEGER*4 GDS__item_finish
+ PARAMETER (GDS__item_finish = 335545052)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2013-02-21 14:59:24 UTC (rev 57684)
@@ -764,6 +764,7 @@
gds_bad_result_set = 335545049;
gds_wrong_message_length = 335545050;
gds_no_output_format = 335545051;
+ gds_item_finish = 335545052;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/common/MsgMetadata.cpp
===================================================================
--- firebird/trunk/src/common/MsgMetadata.cpp 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/common/MsgMetadata.cpp 2013-02-21 14:59:24 UTC (rev 57684)
@@ -25,6 +25,7 @@
#include "firebird.h"
#include "../common/MsgMetadata.h"
#include "../common/utils_proto.h"
+#include "../jrd/align.h"
using namespace Firebird;
@@ -53,83 +54,127 @@
// IMetadataBuilder implementation
virtual void FB_CARG setType(IStatus* status, unsigned index, unsigned type)
{
- MutexLockGuard g(mtx, FB_FUNCTION);
+ try
+ {
+ MutexLockGuard g(mtx, FB_FUNCTION);
- if (!indexError(status, index, "setType"))
+ indexError(index, "setType");
msgMetadata->items[index].type = type;
+ if (!msgMetadata->items[index].length)
+ {
+ unsigned dtype;
+ fb_utils::sqlTypeToDsc(0, type, 0, &dtype, NULL, NULL, NULL);
+ if (dtype < DTYPE_TYPE_MAX)
+ msgMetadata->items[index].length = type_lengths[dtype];
+ }
+
+ // Setting type & length is enough for an item to be ready for use
+ if (msgMetadata->items[index].length)
+ msgMetadata->items[index].finished = true;
+ }
+ catch (const Exception& ex)
+ {
+ ex.stuffException(status);
+ }
}
virtual void FB_CARG setSubType(IStatus* status, unsigned index, unsigned subType)
{
- MutexLockGuard g(mtx, FB_FUNCTION);
+ try
+ {
+ MutexLockGuard g(mtx, FB_FUNCTION);
- if (!indexError(status, index, "setSubType"))
+ indexError(index, "setSubType");
msgMetadata->items[index].subType = subType;
+ }
+ catch (const Exception& ex)
+ {
+ ex.stuffException(status);
+ }
}
virtual void FB_CARG setLength(IStatus* status, unsigned index, unsigned length)
{
- MutexLockGuard g(mtx, FB_FUNCTION);
+ try
+ {
+ MutexLockGuard g(mtx, FB_FUNCTION);
- if (!indexError(status, index, "setLength"))
+ indexError(index, "setLength");
msgMetadata->items[index].length = length;
+
+ // Setting type & length is enough for an item to be ready for use
+ if (msgMetadata->items[index].type)
+ msgMetadata->items[index].finished = true;
+ }
+ catch (const Exception& ex)
+ {
+ ex.stuffException(status);
+ }
}
virtual void FB_CARG setScale(IStatus* status, unsigned index, unsigned scale)
{
- MutexLockGuard g(mtx, FB_FUNCTION);
+ try
+ {
+ MutexLockGuard g(mtx, FB_FUNCTION);
- if (!indexError(status, index, "setScale"))
+ indexError(index, "setScale");
msgMetadata->items[index].scale = scale;
+ }
+ catch (const Exception& ex)
+ {
+ ex.stuffException(status);
+ }
}
virtual IMessageMetadata* FB_CARG getMetadata(IStatus* status)
{
- MutexLockGuard g(mtx, FB_FUNCTION);
+ try
+ {
+ MutexLockGuard g(mtx, FB_FUNCTION);
- if (metadataError(status, "getMetadata"))
+ metadataError("getMetadata");
+
+ unsigned i = msgMetadata->makeOffsets();
+ if (i != ~0u)
+ {
+ (Arg::Gds(isc_item_finish) << Arg::Num(i)).raise();
+ }
+
+ IMessageMetadata* rc = msgMetadata;
+ rc->addRef();
+ msgMetadata = NULL;
+ return rc;
+ }
+ catch (const Exception& ex)
{
- return NULL;
+ ex.stuffException(status);
}
-
- msgMetadata->makeOffsets();
- IMessageMetadata* rc = msgMetadata;
- rc->addRef();
- msgMetadata = NULL;
- return rc;
+ return NULL;
}
private:
RefPtr<MsgMetadata> msgMetadata;
Mutex mtx;
- bool metadataError(IStatus* status, const char* functionName)
+ void metadataError(const char* functionName)
{
if (!msgMetadata)
{
- status->set((Arg::Gds(isc_random) <<
- (string("MetadataBuilder interface is already inactive: IMetadataBuilder::") + functionName)).value());
- return true;
+ (Arg::Gds(isc_random) << (string("MetadataBuilder interface is already inactive: "
+ "IMetadataBuilder::") + functionName)).raise();
}
-
- return false;
}
- bool indexError(IStatus* status, unsigned index, const char* functionName)
+ void indexError(unsigned index, const char* functionName)
{
- if (metadataError(status, functionName))
- {
- return true;
- }
+ metadataError(functionName);
if (index >= msgMetadata->items.getCount())
{
- status->set((Arg::Gds(isc_invalid_index_val) <<
- Arg::Num(index) << (string("IMetadataBuilder::") + functionName)).value());
- return true;
+ (Arg::Gds(isc_invalid_index_val) << Arg::Num(index) << (string("IMetadataBuilder::") +
+ functionName)).raise();
}
-
- return false;
}
};
@@ -139,7 +184,8 @@
namespace Firebird {
-void MsgMetadata::makeOffsets()
+// returns ~0 on success or index of not finished item
+unsigned MsgMetadata::makeOffsets()
{
length = 0;
@@ -149,11 +195,13 @@
if (!param->finished)
{
length = 0;
- return;
+ return n;
}
length = fb_utils::sqlTypeToDsc(length, param->type, param->length,
NULL /*dtype*/, NULL /*length*/, ¶m->offset, ¶m->nullInd);
}
+
+ return ~0;
}
Modified: firebird/trunk/src/common/MsgMetadata.h
===================================================================
--- firebird/trunk/src/common/MsgMetadata.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/common/MsgMetadata.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -227,7 +227,7 @@
}
public:
- void makeOffsets();
+ unsigned makeOffsets();
private:
void raiseIndexError(IStatus* status, unsigned index, const char* method) const
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/include/gen/codetext.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -753,6 +753,7 @@
{"bad_result_set", 335545049},
{"wrong_message_length", 335545050},
{"no_output_format", 335545051},
+ {"item_finish", 335545052},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/include/gen/iberror.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -787,6 +787,7 @@
const ISC_STATUS isc_bad_result_set = 335545049L;
const ISC_STATUS isc_wrong_message_length = 335545050L;
const ISC_STATUS isc_no_output_format = 335545051L;
+const ISC_STATUS isc_item_finish = 335545052L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1231,7 +1232,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1175;
+const ISC_STATUS isc_err_max = 1176;
#else /* c definitions */
@@ -1988,6 +1989,7 @@
#define isc_bad_result_set 335545049L
#define isc_wrong_message_length 335545050L
#define isc_no_output_format 335545051L
+#define isc_item_finish 335545052L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2432,7 +2434,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1175
+#define isc_err_max 1176
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/include/gen/msgs.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -756,6 +756,7 @@
{335545049, "Invalid resultset interface"}, /* bad_result_set */
{335545050, "Message length passed from user application does not match set of columns"}, /* wrong_message_length */
{335545051, "Resultset is missing output format information"}, /* no_output_format */
+ {335545052, "Message metadata not ready - item @1 is not finished"}, /* item_finish */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/include/gen/sql_code.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -752,6 +752,7 @@
{335545049, -901}, /* 729 bad_result_set */
{335545050, -804}, /* 730 wrong_message_length */
{335545051, -804}, /* 731 no_output_format */
+ {335545052, -804}, /* 732 item_finish */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/include/gen/sql_state.h 2013-02-21 14:59:24 UTC (rev 57684)
@@ -752,6 +752,7 @@
{335545049, "26000"}, // 729 bad_result_set
{335545050, "07000"}, // 730 wrong_message_length
{335545051, "07000"}, // 731 no_output_format
+ {335545052, "HY021"}, // 732 item_finish
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/msgs/facilities2.sql 2013-02-21 14:59:24 UTC (rev 57684)
@@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
-('2013-02-17 15:32:05', 'JRD', 0, 732)
+('2013-02-21 18:12:38', 'JRD', 0, 733)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2009-07-16 05:26:11', 'GFIX', 3, 121)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/msgs/messages2.sql 2013-02-21 14:59:24 UTC (rev 57684)
@@ -839,6 +839,7 @@
('bad_result_set', NULL, 'why.cpp', NULL, 0, 729, NULL, 'Invalid resultset interface', NULL, NULL);
('wrong_message_length', NULL, 'why.cpp', NULL, 0, 730, NULL, 'Message length passed from user application does not match set of columns', NULL, NULL);
('no_output_format', NULL, 'why.cpp', NULL, 0, 731, NULL, 'Resultset is missing output format information', NULL, NULL);
+('item_finish', NULL, 'MsgMetadata.cpp', NULL, 0, 732, NULL, 'Message metadata not ready - item @1 is not finished', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2013-02-21 00:48:25 UTC (rev 57683)
+++ firebird/trunk/src/msgs/system_errors2.sql 2013-02-21 14:59:24 UTC (rev 57684)
@@ -738,6 +738,7 @@
(-901, '26', '000', 0, 729, 'bad_result_set', NULL, NULL)
(-804, '07', '000', 0, 730, 'wrong_message_length', NULL, NULL)
(-804, '07', '000', 0, 731, 'no_output_format', NULL, NULL)
+(-804, 'HY', '021', 0, 732, 'item_finish', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|