Skip to content

Commit ed26e8a

Browse files
authored
Replace internal 'dsc' with public 'paramdsc' in the API. So far they're binary compatible and this breaks nothing. But it prevents problems when 'dsc' is to be extended. (#8489)
1 parent 29bca14 commit ed26e8a

File tree

7 files changed

+53
-37
lines changed

7 files changed

+53
-37
lines changed

src/common/dsc.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,19 @@ typedef struct dsc
512512
d.dsc_length = dsc_length;
513513
d.dsc_sub_type = dsc_sub_type;
514514
d.dsc_flags = dsc_flags;
515-
d.dsc_offset = (ULONG)(IPTR)dsc_address;
515+
d.dsc_offset = (ULONG)(IPTR) dsc_address;
516+
return d;
517+
}
518+
519+
operator paramdsc() const
520+
{
521+
paramdsc d;
522+
d.dsc_dtype = dsc_dtype;
523+
d.dsc_scale = dsc_scale;
524+
d.dsc_length = dsc_length;
525+
d.dsc_sub_type = dsc_sub_type;
526+
d.dsc_flags = dsc_flags;
527+
d.dsc_address = dsc_address;
516528
return d;
517529
}
518530

src/include/firebird/FirebirdInterface.idl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ interface XpbBuilder : Disposable
13181318
// Database trace objects
13191319

13201320
struct PerformanceInfo;
1321-
struct dsc;
1321+
struct paramdsc;
13221322

13231323
interface TraceConnection : Versioned
13241324
{
@@ -1365,7 +1365,7 @@ version: // 3.0.4 -> 3.0.5
13651365
interface TraceParams : Versioned
13661366
{
13671367
uint getCount();
1368-
const dsc* getParam(uint idx);
1368+
const paramdsc* getParam(uint idx);
13691369

13701370
version:
13711371
const string getTextUTF8(Status status, uint idx);

src/include/firebird/IdlFbInterfaces.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,7 +5536,7 @@ namespace Firebird
55365536
struct VTable : public IVersioned::VTable
55375537
{
55385538
unsigned (CLOOP_CARG *getCount)(ITraceParams* self) CLOOP_NOEXCEPT;
5539-
const dsc* (CLOOP_CARG *getParam)(ITraceParams* self, unsigned idx) CLOOP_NOEXCEPT;
5539+
const paramdsc* (CLOOP_CARG *getParam)(ITraceParams* self, unsigned idx) CLOOP_NOEXCEPT;
55405540
const char* (CLOOP_CARG *getTextUTF8)(ITraceParams* self, IStatus* status, unsigned idx) CLOOP_NOEXCEPT;
55415541
};
55425542

@@ -5559,9 +5559,9 @@ namespace Firebird
55595559
return ret;
55605560
}
55615561

5562-
const dsc* getParam(unsigned idx)
5562+
const paramdsc* getParam(unsigned idx)
55635563
{
5564-
const dsc* ret = static_cast<VTable*>(this->cloopVTable)->getParam(this, idx);
5564+
const paramdsc* ret = static_cast<VTable*>(this->cloopVTable)->getParam(this, idx);
55655565
return ret;
55665566
}
55675567

@@ -17760,7 +17760,7 @@ namespace Firebird
1776017760
}
1776117761
}
1776217762

17763-
static const dsc* CLOOP_CARG cloopgetParamDispatcher(ITraceParams* self, unsigned idx) CLOOP_NOEXCEPT
17763+
static const paramdsc* CLOOP_CARG cloopgetParamDispatcher(ITraceParams* self, unsigned idx) CLOOP_NOEXCEPT
1776417764
{
1776517765
try
1776617766
{
@@ -17769,7 +17769,7 @@ namespace Firebird
1776917769
catch (...)
1777017770
{
1777117771
StatusType::catchException(0);
17772-
return static_cast<const dsc*>(0);
17772+
return static_cast<const paramdsc*>(0);
1777317773
}
1777417774
}
1777517775

@@ -17803,7 +17803,7 @@ namespace Firebird
1780317803
}
1780417804

1780517805
virtual unsigned getCount() = 0;
17806-
virtual const dsc* getParam(unsigned idx) = 0;
17806+
virtual const paramdsc* getParam(unsigned idx) = 0;
1780717807
virtual const char* getTextUTF8(StatusType* status, unsigned idx) = 0;
1780817808
};
1780917809

src/include/gen/Firebird.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ISC_TIMESTAMP_TZ_EX = record
207207
IntegerPtr = ^Integer;
208208
NativeIntPtr = ^NativeInt;
209209
PerformanceInfoPtr = ^PerformanceInfo;
210-
dscPtr = ^dsc;
210+
paramdscPtr = ^paramdsc;
211211

212212
IReferenceCounted_addRefPtr = procedure(this: IReferenceCounted); cdecl;
213213
IReferenceCounted_releasePtr = function(this: IReferenceCounted): Integer; cdecl;
@@ -611,7 +611,7 @@ ISC_TIMESTAMP_TZ_EX = record
611611
ITraceTransaction_getInitialIDPtr = function(this: ITraceTransaction): Int64; cdecl;
612612
ITraceTransaction_getPreviousIDPtr = function(this: ITraceTransaction): Int64; cdecl;
613613
ITraceParams_getCountPtr = function(this: ITraceParams): Cardinal; cdecl;
614-
ITraceParams_getParamPtr = function(this: ITraceParams; idx: Cardinal): dscPtr; cdecl;
614+
ITraceParams_getParamPtr = function(this: ITraceParams; idx: Cardinal): paramdscPtr; cdecl;
615615
ITraceParams_getTextUTF8Ptr = function(this: ITraceParams; status: IStatus; idx: Cardinal): PAnsiChar; cdecl;
616616
ITraceStatement_getStmtIDPtr = function(this: ITraceStatement): Int64; cdecl;
617617
ITraceStatement_getPerfPtr = function(this: ITraceStatement): PerformanceInfoPtr; cdecl;
@@ -3089,15 +3089,15 @@ ITraceParams = class(IVersioned)
30893089
const VERSION = 3;
30903090

30913091
function getCount(): Cardinal;
3092-
function getParam(idx: Cardinal): dscPtr;
3092+
function getParam(idx: Cardinal): paramdscPtr;
30933093
function getTextUTF8(status: IStatus; idx: Cardinal): PAnsiChar;
30943094
end;
30953095

30963096
ITraceParamsImpl = class(ITraceParams)
30973097
constructor create;
30983098

30993099
function getCount(): Cardinal; virtual; abstract;
3100-
function getParam(idx: Cardinal): dscPtr; virtual; abstract;
3100+
function getParam(idx: Cardinal): paramdscPtr; virtual; abstract;
31013101
function getTextUTF8(status: IStatus; idx: Cardinal): PAnsiChar; virtual; abstract;
31023102
end;
31033103

@@ -9084,7 +9084,7 @@ function ITraceParams.getCount(): Cardinal;
90849084
Result := TraceParamsVTable(vTable).getCount(Self);
90859085
end;
90869086

9087-
function ITraceParams.getParam(idx: Cardinal): dscPtr;
9087+
function ITraceParams.getParam(idx: Cardinal): paramdscPtr;
90889088
begin
90899089
Result := TraceParamsVTable(vTable).getParam(Self, idx);
90909090
end;
@@ -15416,7 +15416,7 @@ function ITraceParamsImpl_getCountDispatcher(this: ITraceParams): Cardinal; cdec
1541615416
end
1541715417
end;
1541815418

15419-
function ITraceParamsImpl_getParamDispatcher(this: ITraceParams; idx: Cardinal): dscPtr; cdecl;
15419+
function ITraceParamsImpl_getParamDispatcher(this: ITraceParams; idx: Cardinal): paramdscPtr; cdecl;
1542015420
begin
1542115421
Result := nil;
1542215422
try

src/jrd/trace/TraceObjects.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace
6161

6262
// Convert text descriptor into UTF8 string.
6363
// Binary data converted into HEX representation.
64-
bool descToUTF8(const dsc* param, string& result)
64+
bool descToUTF8(const paramdsc* param, string& result)
6565
{
6666
UCHAR* address;
6767
USHORT length;
@@ -83,7 +83,7 @@ bool descToUTF8(const dsc* param, string& result)
8383
return false;
8484
}
8585

86-
if (param->getCharSet() == CS_BINARY)
86+
if (param->dsc_sub_type == CS_BINARY)
8787
{
8888
// Convert OCTETS and [VAR]BINARY to HEX string
8989

@@ -312,15 +312,19 @@ void TraceSQLStatementImpl::DSQLParamsImpl::fillParams()
312312
if (idx >= m_descs.getCount())
313313
m_descs.getBuffer(idx + 1);
314314

315-
dsc& desc = m_descs[idx];
315+
auto& desc = m_descs[idx];
316316

317317
desc = fmt->fmt_desc[parameter->par_parameter];
318+
318319
// Use descriptor for nulls signaling
319-
if (parameter->par_null)
320+
if (const auto nullParam = parameter->par_null)
320321
{
321-
if (*(SSHORT*) (m_buffer + (IPTR) fmt->fmt_desc[parameter->par_null->par_parameter].dsc_address))
322+
const auto& nullDesc = fmt->fmt_desc[nullParam->par_parameter];
323+
324+
if (*(SSHORT*) (m_buffer + (IPTR) nullDesc.dsc_address))
322325
desc.dsc_flags |= DSC_null;
323326
}
327+
324328
// Even if plugin try to change data in buffer (which is pointless)
325329
// most likely it is safe because client buffer is writeble though
326330
// in EXE_send() it is declared as const.
@@ -336,19 +340,19 @@ FB_SIZE_T TraceSQLStatementImpl::DSQLParamsImpl::getCount()
336340
return m_descs.getCount();
337341
}
338342

339-
const dsc* TraceSQLStatementImpl::DSQLParamsImpl::getParam(FB_SIZE_T idx)
343+
const paramdsc* TraceSQLStatementImpl::DSQLParamsImpl::getParam(FB_SIZE_T idx)
340344
{
341345
fillParams();
342346

343-
if (idx >= 0 && idx < m_descs.getCount())
347+
if (idx < m_descs.getCount())
344348
return &m_descs[idx];
345349

346350
return NULL;
347351
}
348352

349353
const char* TraceSQLStatementImpl::DSQLParamsImpl::getTextUTF8(CheckStatusWrapper* status, FB_SIZE_T idx)
350354
{
351-
const dsc* param = getParam(idx);
355+
const paramdsc* const param = getParam(idx);
352356

353357
if (descToUTF8(param, m_tempUTF8))
354358
return m_tempUTF8.c_str();
@@ -378,14 +382,14 @@ FB_SIZE_T TraceParamsImpl::getCount()
378382
return m_descs->getCount();
379383
}
380384

381-
const dsc* TraceParamsImpl::getParam(FB_SIZE_T idx)
385+
const paramdsc* TraceParamsImpl::getParam(FB_SIZE_T idx)
382386
{
383387
return m_descs->getParam(idx);
384388
}
385389

386390
const char* TraceParamsImpl::getTextUTF8(CheckStatusWrapper* status, FB_SIZE_T idx)
387391
{
388-
const dsc* param = getParam(idx);
392+
const paramdsc* const param = getParam(idx);
389393

390394
if (descToUTF8(param, m_tempUTF8))
391395
return m_tempUTF8.c_str();
@@ -465,7 +469,7 @@ void TraceDscFromMsg::fillParams()
465469
const dsc* fmtDesc = m_format->fmt_desc.begin();
466470
const dsc* const fmtEnd = m_format->fmt_desc.end();
467471

468-
dsc* desc = m_descs.getBuffer(m_format->fmt_count / 2);
472+
paramdsc* desc = m_descs.getBuffer(m_format->fmt_count / 2);
469473

470474
for (; fmtDesc < fmtEnd; fmtDesc += 2, desc++)
471475
{
@@ -477,7 +481,7 @@ void TraceDscFromMsg::fillParams()
477481
const ULONG nullOffset = (IPTR) fmtDesc[1].dsc_address;
478482
const SSHORT* const nullPtr = (const SSHORT*) (m_inMsg + nullOffset);
479483
if (*nullPtr == -1)
480-
desc->setNull();
484+
desc->dsc_flags |= DSC_null;
481485
}
482486
}
483487

src/jrd/trace/TraceObjects.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ class TraceSQLStatementImpl :
256256
}
257257

258258
FB_SIZE_T getCount();
259-
const dsc* getParam(FB_SIZE_T idx);
259+
const paramdsc* getParam(FB_SIZE_T idx);
260260
const char* getTextUTF8(Firebird::CheckStatusWrapper* status, FB_SIZE_T idx);
261261

262262
private:
263263
void fillParams();
264264

265265
DsqlRequest* const m_stmt;
266266
const UCHAR* m_buffer;
267-
Firebird::HalfStaticArray<dsc, 16> m_descs;
267+
Firebird::HalfStaticArray<paramdsc, 16> m_descs;
268268
Firebird::string m_tempUTF8;
269269
};
270270

@@ -333,7 +333,7 @@ class TraceParamsImpl :
333333

334334
// TraceParams implementation
335335
FB_SIZE_T getCount();
336-
const dsc* getParam(FB_SIZE_T idx);
336+
const paramdsc* getParam(FB_SIZE_T idx);
337337
const char* getTextUTF8(Firebird::CheckStatusWrapper* status, FB_SIZE_T idx);
338338

339339
private:
@@ -356,11 +356,11 @@ class TraceDescriptors
356356
return m_descs.getCount();
357357
}
358358

359-
const dsc* getParam(FB_SIZE_T idx)
359+
const paramdsc* getParam(FB_SIZE_T idx)
360360
{
361361
fillParams();
362362

363-
if (/*idx >= 0 &&*/ idx < m_descs.getCount())
363+
if (idx < m_descs.getCount())
364364
return &m_descs[idx];
365365

366366
return NULL;
@@ -374,7 +374,7 @@ class TraceDescriptors
374374
protected:
375375
virtual void fillParams() = 0;
376376

377-
Firebird::HalfStaticArray<dsc, 16> m_descs;
377+
Firebird::HalfStaticArray<paramdsc, 16> m_descs;
378378

379379
private:
380380
TraceParamsImpl m_traceParams;
@@ -427,7 +427,7 @@ class TraceDscFromDsc : public TraceDescriptors
427427
else
428428
{
429429
m_descs.grow(1);
430-
m_descs[0].setNull();
430+
m_descs[0].dsc_flags |= DSC_null;
431431
}
432432
}
433433

src/utilities/ntrace/TracePluginImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ void TracePluginImpl::appendParams(ITraceParams* params)
815815

816816
for (FB_SIZE_T i = 0; i < paramcount; i++)
817817
{
818-
const struct dsc* parameters = params->getParam(i);
818+
const paramdsc* const parameters = params->getParam(i);
819819

820820
// See if we need to print any more arguments
821821
if (config.max_arg_count && i >= config.max_arg_count)
@@ -829,7 +829,7 @@ void TracePluginImpl::appendParams(ITraceParams* params)
829829
switch (parameters->dsc_dtype)
830830
{
831831
case dtype_text:
832-
if (parameters->getTextType() == fb_text_subtype_binary)
832+
if (parameters->dsc_sub_type == fb_text_subtype_binary)
833833
paramtype.printf("binary(%d)", parameters->dsc_length);
834834
else
835835
paramtype.printf("char(%d)", parameters->dsc_length);
@@ -838,7 +838,7 @@ void TracePluginImpl::appendParams(ITraceParams* params)
838838
paramtype.printf("cstring(%d)", parameters->dsc_length - 1);
839839
break;
840840
case dtype_varying:
841-
if (parameters->getTextType() == fb_text_subtype_binary)
841+
if (parameters->dsc_sub_type == fb_text_subtype_binary)
842842
paramtype.printf("varbinary(%d)", parameters->dsc_length - 2);
843843
else
844844
paramtype.printf("varchar(%d)", parameters->dsc_length - 2);

0 commit comments

Comments
 (0)