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