Generate complete blr for a dsqlScratch.
| 226 | |
| 227 | // Generate complete blr for a dsqlScratch. |
| 228 | void GEN_statement(DsqlCompilerScratch* scratch, DmlNode* node) |
| 229 | { |
| 230 | DsqlStatement* statement = scratch->getDsqlStatement(); |
| 231 | |
| 232 | if (statement->getBlrVersion() == 4) |
| 233 | scratch->appendUChar(blr_version4); |
| 234 | else |
| 235 | scratch->appendUChar(blr_version5); |
| 236 | |
| 237 | const bool block = statement->getType() == DsqlStatement::TYPE_EXEC_BLOCK || |
| 238 | statement->getType() == DsqlStatement::TYPE_SELECT_BLOCK; |
| 239 | |
| 240 | // To parse sub-routines messages, they must not have that begin...end pair. |
| 241 | // And since it appears to be unnecessary for execute block too, do not generate them. |
| 242 | if (!block) |
| 243 | scratch->appendUChar(blr_begin); |
| 244 | |
| 245 | scratch->putOuterMaps(); |
| 246 | GEN_hidden_variables(scratch); |
| 247 | |
| 248 | switch (statement->getType()) |
| 249 | { |
| 250 | case DsqlStatement::TYPE_SELECT: |
| 251 | case DsqlStatement::TYPE_SELECT_UPD: |
| 252 | case DsqlStatement::TYPE_EXEC_BLOCK: |
| 253 | case DsqlStatement::TYPE_SELECT_BLOCK: |
| 254 | node->genBlr(scratch); |
| 255 | break; |
| 256 | |
| 257 | ///case DsqlStatement::TYPE_RETURNING_CURSOR: |
| 258 | default: |
| 259 | { |
| 260 | dsql_msg* message = statement->getSendMsg(); |
| 261 | if (!message->msg_parameter) |
| 262 | statement->setSendMsg(NULL); |
| 263 | else |
| 264 | { |
| 265 | GEN_port(scratch, message); |
| 266 | scratch->appendUChar(blr_receive_batch); |
| 267 | scratch->appendUChar(message->msg_number); |
| 268 | } |
| 269 | message = statement->getReceiveMsg(); |
| 270 | if (!message->msg_parameter) |
| 271 | statement->setReceiveMsg(NULL); |
| 272 | else |
| 273 | GEN_port(scratch, message); |
| 274 | node->genBlr(scratch); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | if (!block) |
| 279 | scratch->appendUChar(blr_end); |
| 280 | |
| 281 | scratch->appendUChar(blr_eoc); |
| 282 | } |
| 283 | |
| 284 | |
| 285 | /** |
no test coverage detected