| 61 | } |
| 62 | |
| 63 | void BlrFromMessage::buildBlr(IMessageMetadata* metadata) |
| 64 | { |
| 65 | if (!metadata) |
| 66 | return; |
| 67 | |
| 68 | LocalStatus ls; |
| 69 | CheckStatusWrapper st(&ls); |
| 70 | |
| 71 | expectedMessageLength = metadata->getMessageLength(&st); |
| 72 | check(&st); |
| 73 | |
| 74 | getBlrData().clear(); |
| 75 | |
| 76 | const unsigned count = metadata->getCount(&st); |
| 77 | fb_assert(count < MAX_USHORT / 2); |
| 78 | |
| 79 | if (count == 0) |
| 80 | return; // If there isn't an SQLDA, don't bother with anything else. |
| 81 | |
| 82 | appendVersion(); |
| 83 | appendUChar(blr_begin); |
| 84 | appendUChar(blr_message); |
| 85 | appendUChar(0); |
| 86 | appendUShort(count * 2); |
| 87 | |
| 88 | unsigned msgLen = 0; |
| 89 | |
| 90 | for (unsigned i = 0; i < count; ++i) |
| 91 | { |
| 92 | unsigned dtype = metadata->getType(&st, i) & ~1; |
| 93 | check(&st); |
| 94 | unsigned len = metadata->getLength(&st, i); |
| 95 | check(&st); |
| 96 | int scale = metadata->getScale(&st, i); |
| 97 | check(&st); |
| 98 | unsigned charSet = metadata->getCharSet(&st, i); |
| 99 | check(&st); |
| 100 | int subType = metadata->getSubType(&st, i); |
| 101 | check(&st); |
| 102 | |
| 103 | switch (dtype) |
| 104 | { |
| 105 | case SQL_VARYING: |
| 106 | appendUChar(blr_varying2); |
| 107 | appendUShort(charSet); |
| 108 | appendUShort(len); |
| 109 | dtype = dtype_varying; |
| 110 | len += sizeof(USHORT); |
| 111 | break; |
| 112 | |
| 113 | case SQL_TEXT: |
| 114 | appendUChar(blr_text2); |
| 115 | appendUShort(charSet); |
| 116 | appendUShort(len); |
| 117 | dtype = dtype_text; |
| 118 | break; |
| 119 | |
| 120 | case SQL_DEC16: |
nothing calls this directly
no test coverage detected