mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 20:03:02 +01:00
Improvements and corrections to message builder and UDR.
This commit is contained in:
parent
e85e525e77
commit
768b79c361
@ -690,7 +690,7 @@ FB_UDR_BEGIN_TRIGGER(replicate_persons)
|
||||
FB_TRIGGER_MESSAGE(FieldsMessage,
|
||||
(FB_INTEGER, id, "ID")
|
||||
(FB_BLOB, info, "INFO")
|
||||
(FB_VARCHAR(60 * 4), address, "ADDRESS")
|
||||
///(FB_VARCHAR(60 * 4), address, "ADDRESS")
|
||||
(FB_VARCHAR(60 * 4), name, "NAME")
|
||||
);
|
||||
|
||||
@ -753,13 +753,13 @@ FB_UDR_BEGIN_TRIGGER(replicate_persons)
|
||||
"execute block (\n"
|
||||
" id type of column PERSONS.ID = ?,\n"
|
||||
" info type of column PERSONS.INFO = ?,\n"
|
||||
" address type of column PERSONS.ADDRESS = ?,\n"
|
||||
///" address type of column PERSONS.ADDRESS = ?,\n"
|
||||
" name type of column PERSONS.NAME = ?\n"
|
||||
")"
|
||||
"as\n"
|
||||
"begin\n"
|
||||
" execute statement ('insert into persons (id, name, address, info)\n"
|
||||
" values (?, ?, ?, ?)') (:id, :name, :address, :info)\n"
|
||||
" execute statement ('insert into persons (id, name/***, address***/, info)\n"
|
||||
" values (?, ?/***, ?***/, ?)') (:id, :name/***, :address***/, :info)\n"
|
||||
" on external data source '");
|
||||
strcat(buffer, outSqlDa->sqlvar[0].sqldata + sizeof(short));
|
||||
strcat(buffer, "';\nend");
|
||||
|
@ -114,6 +114,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void FB_CARG setCharSet(IStatus* status, unsigned index, unsigned charSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
MutexLockGuard g(mtx, FB_FUNCTION);
|
||||
|
||||
indexError(index, "setCharSet");
|
||||
msgMetadata->items[index].charSet = charSet;
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuffException(status);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void FB_CARG setScale(IStatus* status, unsigned index, unsigned scale)
|
||||
{
|
||||
try
|
||||
@ -129,6 +144,23 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void FB_CARG truncate(IStatus* status, unsigned count)
|
||||
{
|
||||
try
|
||||
{
|
||||
MutexLockGuard g(mtx, FB_FUNCTION);
|
||||
|
||||
if (count != 0)
|
||||
indexError(count - 1, "truncate");
|
||||
|
||||
msgMetadata->items.shrink(count);
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuffException(status);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void FB_CARG moveNameToIndex(IStatus* status, const char* name, unsigned index)
|
||||
{
|
||||
try
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
subType(0),
|
||||
length(0),
|
||||
scale(0),
|
||||
charset(0),
|
||||
charSet(0),
|
||||
offset(0),
|
||||
nullInd(0),
|
||||
nullable(false),
|
||||
@ -66,7 +66,7 @@ public:
|
||||
subType(v.subType),
|
||||
length(v.length),
|
||||
scale(v.scale),
|
||||
charset(v.charset),
|
||||
charSet(v.charSet),
|
||||
offset(v.offset),
|
||||
nullInd(v.nullInd),
|
||||
nullable(v.nullable),
|
||||
@ -82,7 +82,7 @@ public:
|
||||
unsigned subType;
|
||||
unsigned length;
|
||||
unsigned scale;
|
||||
unsigned charset;
|
||||
unsigned charSet;
|
||||
unsigned offset;
|
||||
unsigned nullInd;
|
||||
bool nullable;
|
||||
@ -193,12 +193,12 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual unsigned FB_CARG getCharset(IStatus* status, unsigned index) const
|
||||
virtual unsigned FB_CARG getCharSet(IStatus* status, unsigned index) const
|
||||
{
|
||||
if (index < items.getCount())
|
||||
return items[index].charset;
|
||||
return items[index].charSet;
|
||||
|
||||
raiseIndexError(status, index, "getCharset");
|
||||
raiseIndexError(status, index, "getCharSet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -89,25 +89,25 @@ MetadataFromBlr::MetadataFromBlr(unsigned aBlrLength, const unsigned char* aBlr,
|
||||
{
|
||||
case blr_text:
|
||||
item->type = SQL_TEXT;
|
||||
item->charset = CS_dynamic;
|
||||
item->charSet = CS_dynamic;
|
||||
item->length = rdr.getWord();
|
||||
break;
|
||||
|
||||
case blr_varying:
|
||||
item->type = SQL_VARYING;
|
||||
item->charset = CS_dynamic;
|
||||
item->charSet = CS_dynamic;
|
||||
item->length = rdr.getWord();
|
||||
break;
|
||||
|
||||
case blr_text2:
|
||||
item->type = SQL_TEXT;
|
||||
item->charset = rdr.getWord();
|
||||
item->charSet = rdr.getWord();
|
||||
item->length = rdr.getWord();
|
||||
break;
|
||||
|
||||
case blr_varying2:
|
||||
item->type = SQL_VARYING;
|
||||
item->charset = rdr.getWord();
|
||||
item->charSet = rdr.getWord();
|
||||
item->length = rdr.getWord();
|
||||
break;
|
||||
|
||||
@ -165,7 +165,7 @@ MetadataFromBlr::MetadataFromBlr(unsigned aBlrLength, const unsigned char* aBlr,
|
||||
item->type = SQL_BLOB;
|
||||
item->length = sizeof(ISC_QUAD);
|
||||
item->subType = rdr.getWord();
|
||||
item->charset = rdr.getWord();
|
||||
item->charSet = rdr.getWord();
|
||||
break;
|
||||
|
||||
case blr_bool:
|
||||
|
@ -1266,7 +1266,7 @@ static USHORT parse_metadata(dsql_req* request, IMessageMetadata* meta,
|
||||
check(&st);
|
||||
desc.dsc_sub_type = meta->getSubType(&st, index);
|
||||
check(&st);
|
||||
unsigned textType = meta->getCharset(&st, index);
|
||||
unsigned textType = meta->getCharSet(&st, index);
|
||||
check(&st);
|
||||
desc.setTextType(textType);
|
||||
desc.dsc_address = (UCHAR*)(IPTR) dataOffset;
|
||||
|
@ -58,9 +58,8 @@
|
||||
static void setup(::Firebird::IStatus* status, ::Firebird::IMetadataBuilder* builder) \
|
||||
{ \
|
||||
unsigned index = 0; \
|
||||
FB_BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_META, size, fields) \
|
||||
\
|
||||
moveNames \
|
||||
FB_BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_META, size, fields) \
|
||||
} \
|
||||
\
|
||||
name(::Firebird::IMaster* master) \
|
||||
@ -163,6 +162,16 @@
|
||||
builder->setType(status, index, SQL_VARYING); \
|
||||
builder->setLength(status, index, len);
|
||||
|
||||
#define FB__META_FB_INTL_CHAR(len, charSet) \
|
||||
builder->setType(status, index, SQL_TEXT); \
|
||||
builder->setLength(status, index, len); \
|
||||
builder->setCharSet(status, index, charSet);
|
||||
|
||||
#define FB__META_FB_INTL_VARCHAR(len, charSet) \
|
||||
builder->setType(status, index, SQL_VARYING); \
|
||||
builder->setLength(status, index, len); \
|
||||
builder->setCharSet(status, index, charSet);
|
||||
|
||||
#define FB__META_FB_SMALLINT FB__META_FB_SCALED_SMALLINT(0)
|
||||
#define FB__META_FB_INTEGER FB__META_FB_SCALED_INTEGER(0)
|
||||
#define FB__META_FB_BIGINT FB__META_FB_SCALED_BIGINT(0)
|
||||
@ -194,8 +203,9 @@
|
||||
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_Y0
|
||||
|
||||
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_I(name, size, fields) \
|
||||
index = 0; \
|
||||
FB_BOOST_PP_SEQ_FOR_EACH_I(FB_TRIGGER_MESSAGE_MOVE_NAME, size, fields)
|
||||
FB_BOOST_PP_SEQ_FOR_EACH_I(FB_TRIGGER_MESSAGE_MOVE_NAME, size, fields) \
|
||||
builder->truncate(status, index); \
|
||||
index = 0;
|
||||
|
||||
#define FB_TRIGGER_MESSAGE_MOVE_NAME(r, _, i, xy) \
|
||||
builder->moveNameToIndex(status, FB_BOOST_PP_TUPLE_ELEM(_, 2, xy), index++);
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
virtual unsigned FB_CARG getSubType(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getLength(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getScale(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getCharset(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getCharSet(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getOffset(IStatus* status, unsigned index) const = 0;
|
||||
virtual unsigned FB_CARG getNullOffset(IStatus* status, unsigned index) const = 0;
|
||||
|
||||
@ -118,13 +118,15 @@ public:
|
||||
virtual void FB_CARG setType(IStatus* status, unsigned index, unsigned type) = 0;
|
||||
virtual void FB_CARG setSubType(IStatus* status, unsigned index, unsigned subType) = 0;
|
||||
virtual void FB_CARG setLength(IStatus* status, unsigned index, unsigned length) = 0;
|
||||
virtual void FB_CARG setCharSet(IStatus* status, unsigned index, unsigned charSet) = 0;
|
||||
virtual void FB_CARG setScale(IStatus* status, unsigned index, unsigned scale) = 0;
|
||||
|
||||
virtual void FB_CARG truncate(IStatus* status, unsigned count) = 0;
|
||||
virtual void FB_CARG moveNameToIndex(IStatus* status, const char* name, unsigned index) = 0;
|
||||
|
||||
virtual IMessageMetadata* FB_CARG getMetadata(IStatus* status) = 0;
|
||||
};
|
||||
#define FB_METADATA_BUILDER_VERSION (FB_REFCOUNTED_VERSION + 6)
|
||||
#define FB_METADATA_BUILDER_VERSION (FB_REFCOUNTED_VERSION + 8)
|
||||
|
||||
class IResultSet : public IRefCounted
|
||||
{
|
||||
|
@ -896,7 +896,7 @@ void ExtEngineManager::Trigger::execute(thread_db* tdbb, ExternalTrigger::Action
|
||||
|
||||
LocalStatus status;
|
||||
trigger->execute(&status, attInfo->context, action,
|
||||
(oldRpb ? oldMsg.begin() : NULL), (newRpb ? newMsg.begin() : NULL));
|
||||
(oldMsg.hasData() ? oldMsg.begin() : NULL), (newMsg.hasData() ? newMsg.begin() : NULL));
|
||||
status.check();
|
||||
}
|
||||
|
||||
@ -941,7 +941,7 @@ void ExtEngineManager::Trigger::setValues(thread_db* tdbb, Array<UCHAR>& msgBuff
|
||||
return;
|
||||
|
||||
UCHAR* p = msgBuffer.getBuffer(format->fmt_length);
|
||||
///memset(p, 0, format->fmt_length);
|
||||
memset(p, 0, format->fmt_length);
|
||||
|
||||
for (unsigned i = 0; i < format->fmt_count / 2; ++i)
|
||||
{
|
||||
|
@ -54,13 +54,13 @@ namespace
|
||||
{
|
||||
case dtype_text:
|
||||
item.type = SQL_TEXT;
|
||||
item.charset = desc->dsc_ttype();
|
||||
item.charSet = desc->dsc_ttype();
|
||||
item.length = desc->dsc_length;
|
||||
break;
|
||||
|
||||
case dtype_varying:
|
||||
item.type = SQL_VARYING;
|
||||
item.charset = desc->dsc_ttype();
|
||||
item.charSet = desc->dsc_ttype();
|
||||
fb_assert(desc->dsc_length >= sizeof(USHORT));
|
||||
item.length = desc->dsc_length - sizeof(USHORT);
|
||||
break;
|
||||
@ -123,7 +123,7 @@ namespace
|
||||
item.type = SQL_BLOB;
|
||||
item.length = sizeof(ISC_QUAD);
|
||||
item.subType = desc->dsc_sub_type;
|
||||
item.charset = desc->getTextType();
|
||||
item.charSet = desc->getTextType();
|
||||
break;
|
||||
|
||||
case dtype_boolean:
|
||||
|
@ -75,7 +75,7 @@ Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool a
|
||||
desc->dsc_length = descLength;
|
||||
desc->dsc_scale = params->getScale(&status, i);
|
||||
desc->dsc_sub_type = params->getSubType(&status, i);
|
||||
desc->setTextType(params->getCharset(&status, i));
|
||||
desc->setTextType(params->getCharSet(&status, i));
|
||||
desc->dsc_address = (UCHAR*)(IPTR) descOffset;
|
||||
desc->dsc_flags = (params->isNullable(&status, i) ? DSC_nullable : 0);
|
||||
|
||||
|
@ -105,14 +105,14 @@ void BlrFromMessage::buildBlr(IMessageMetadata* metadata)
|
||||
checkStatus(&st);
|
||||
unsigned scale = metadata->getScale(&st, i);
|
||||
checkStatus(&st);
|
||||
unsigned charset = metadata->getCharset(&st, i);
|
||||
unsigned charSet = metadata->getCharSet(&st, i);
|
||||
checkStatus(&st);
|
||||
|
||||
switch (dtype)
|
||||
{
|
||||
case SQL_VARYING:
|
||||
appendUChar(blr_varying2);
|
||||
appendUShort(charset);
|
||||
appendUShort(charSet);
|
||||
appendUShort(len);
|
||||
dtype = dtype_varying;
|
||||
len += sizeof(USHORT);
|
||||
@ -120,7 +120,7 @@ void BlrFromMessage::buildBlr(IMessageMetadata* metadata)
|
||||
|
||||
case SQL_TEXT:
|
||||
appendUChar(blr_text2);
|
||||
appendUShort(charset);
|
||||
appendUShort(charSet);
|
||||
appendUShort(len);
|
||||
dtype = dtype_text;
|
||||
break;
|
||||
@ -158,7 +158,7 @@ void BlrFromMessage::buildBlr(IMessageMetadata* metadata)
|
||||
case SQL_BLOB:
|
||||
appendUChar(blr_blob2);
|
||||
appendUShort(metadata->getSubType(&st, i));
|
||||
appendUShort(charset);
|
||||
appendUShort(charSet);
|
||||
dtype = dtype_blob;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user