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

Fixed #8006: Int128 datatype not supported in UDR

This commit is contained in:
AlexPeshkoff 2024-02-14 17:25:26 +03:00
parent 11920822e0
commit 0475c32072
2 changed files with 19 additions and 5 deletions

View File

@ -36,6 +36,7 @@
static IMaster* master = fb_get_master_interface();
static IDecFloat16* idf16 = NULL;
static IInt128* ii128 = NULL;
int main()
{
@ -56,6 +57,7 @@ int main()
try
{
idf16 = master->getUtilInterface()->getDecFloat16(&status);
ii128 = master->getUtilInterface()->getInt128(&status);
att = prov->attachDatabase(&status, dbName, 0, NULL);
tra = att->startTransaction(&status, 0, NULL);
@ -79,6 +81,7 @@ int main()
(FB_VARCHAR(31), relationName)
(FB_VARCHAR(100), description)
(FB_DECFLOAT16, df16)
(FB_INT128, iHuge)
) output(&status, master);
input.clear();
@ -86,25 +89,28 @@ int main()
rs = att->openCursor(&status, tra, 0,
"select rdb$relation_id, rdb$relation_name, rdb$description,"
" cast (rdb$relation_id as decfloat(16)) * 0.05 as df16"
" cast (rdb$relation_id as decfloat(16)) * 0.05 as df16,"
" cast (rdb$relation_id as int128) * 212778764464767 as iHuge"
" from rdb$relations"
" where rdb$system_flag = ?"
" order by rdb$relation_id",
SAMPLES_DIALECT, input.getMetadata(), input.getData(), output.getMetadata(), NULL, 0);
printf(" ID Name/comment\n");
printf(" ID Name datatype-tests (perform some arithmetics) /comment\n");
while (rs->fetchNext(&status, output.getData()) == IStatus::RESULT_OK)
{
unsigned lRelName = output->relationNameNull ? 0 : output->relationName.length;
unsigned lDesc = output->descriptionNull ? 0 : output->description.length;
char t16[IDecFloat16::STRING_SIZE];
idf16->toString(&status, &output->df16, sizeof(t16), t16);
char huge[IInt128::STRING_SIZE];
ii128->toString(&status, &output->iHuge, -3, sizeof(huge), huge);
printf("%4d %*.*s%c%*.*s (%s)\n", output->relationId,
printf("%4d %*.*s [Decfloat16:%s Int128:%s] %c%*.*s\n", output->relationId,
lRelName, lRelName, output->relationName.str,
t16, huge,
lDesc ? '/' : ' ',
lDesc, lDesc, output->description.str,
t16);
lDesc, lDesc, output->description.str);
}
rs->close(&status);

View File

@ -131,6 +131,11 @@
builder->setLength(status, index, sizeof(ISC_INT64)); \
builder->setScale(status, index, scale);
#define FB__META_FB_SCALED_INT128(scale) \
builder->setType(status, index, SQL_INT128); \
builder->setLength(status, index, sizeof(FB_I128)); \
builder->setScale(status, index, scale);
#define FB__META_FB_FLOAT \
builder->setType(status, index, SQL_FLOAT); \
builder->setLength(status, index, sizeof(float));
@ -204,15 +209,18 @@
#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)
#define FB__META_FB_INT128 FB__META_FB_SCALED_INT128(0)
// Types - struct
#define FB__TYPE_FB_SCALED_SMALLINT(x) ISC_SHORT
#define FB__TYPE_FB_SCALED_INTEGER(x) ISC_LONG
#define FB__TYPE_FB_SCALED_BIGINT(x) FB__INT64_ALIGNAS ISC_INT64
#define FB__TYPE_FB_SCALED_INT128(x) FB__INT64_ALIGNAS FB_I128
#define FB__TYPE_FB_SMALLINT ISC_SHORT
#define FB__TYPE_FB_INTEGER ISC_LONG
#define FB__TYPE_FB_BIGINT FB__INT64_ALIGNAS ISC_INT64
#define FB__TYPE_FB_INT128 FB__INT64_ALIGNAS FB_I128
#define FB__TYPE_FB_FLOAT float
#define FB__TYPE_FB_DOUBLE double
#define FB__TYPE_FB_DECFLOAT16 FB__INT64_ALIGNAS FB_DEC16