MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / createFormat

Method createFormat

src/jrd/Routine.cpp:58–110  ·  view source on GitHub ↗

Create a Format based on an IMessageMetadata.

Source from the content-addressed store, hash-verified

56
57// Create a Format based on an IMessageMetadata.
58Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool addEof)
59{
60 FbLocalStatus status;
61
62 unsigned count = params->getCount(&status);
63 status.check();
64
65 Format* format = Format::newFormat(pool, count * 2 + (addEof ? 1 : 0));
66 unsigned runOffset = 0;
67
68 dsc* desc = format->fmt_desc.begin();
69
70 for (unsigned i = 0; i < count; ++i)
71 {
72 unsigned descOffset, nullOffset, descDtype, descLength;
73
74 unsigned type = params->getType(&status, i);
75 status.check();
76 unsigned len = params->getLength(&status, i);
77 status.check();
78 runOffset = fb_utils::sqlTypeToDsc(runOffset, type, len, &descDtype, &descLength,
79 &descOffset, &nullOffset);
80
81 desc->clear();
82 desc->dsc_dtype = descDtype;
83 desc->dsc_length = descLength;
84 desc->dsc_scale = params->getScale(&status, i);
85 status.check();
86 desc->dsc_sub_type = params->getSubType(&status, i);
87 status.check();
88 desc->setTextType(params->getCharSet(&status, i));
89 status.check();
90 desc->dsc_address = (UCHAR*)(IPTR) descOffset;
91 desc->dsc_flags = (params->isNullable(&status, i) ? DSC_nullable : 0);
92 status.check();
93
94 ++desc;
95 desc->makeShort(0, (SSHORT*)(IPTR) nullOffset);
96
97 ++desc;
98 }
99
100 if (addEof)
101 {
102 // Next item is aligned on USHORT, so as the previous one.
103 desc->makeShort(0, (SSHORT*)(IPTR) runOffset);
104 runOffset += sizeof(USHORT);
105 }
106
107 format->fmt_length = runOffset;
108
109 return format;
110}
111
112void Routine::setStatement(Statement* value)
113{

Callers

nothing calls this directly

Calls 13

sqlTypeToDscFunction · 0.85
setTextTypeMethod · 0.80
makeShortMethod · 0.80
getCountMethod · 0.45
checkMethod · 0.45
beginMethod · 0.45
getTypeMethod · 0.45
getLengthMethod · 0.45
clearMethod · 0.45
getScaleMethod · 0.45
getSubTypeMethod · 0.45
getCharSetMethod · 0.45

Tested by

no test coverage detected