MCPcopy Create free account
hub / github.com/crate/crate / bind

Method bind

server/src/main/java/io/crate/session/Session.java:403–453  ·  view source on GitHub ↗
(String portalName,
                     String statementName,
                     List<Object> params,
                     FormatCodes.@Nullable FormatCode[] resultFormatCodes)

Source from the content-addressed store, hash-verified

401 }
402
403 public void bind(String portalName,
404 String statementName,
405 List<Object> params,
406 FormatCodes.@Nullable FormatCode[] resultFormatCodes) {
407 if (LOGGER.isDebugEnabled()) {
408 LOGGER.debug("method=bind portalName={} statementName={} params={}", portalName, statementName, params);
409 }
410 PreparedStmt preparedStmt;
411 try {
412 preparedStmt = getSafeStmt(statementName);
413 } catch (Throwable t) {
414 jobsLogs.logPreExecutionFailure(UUIDs.dirtyUUID(), id, "", SQLExceptions.messageOf(t), sessionSettings.sessionUser());
415 throw t;
416 }
417
418 Portal portal = new Portal(
419 portalName,
420 preparedStmt,
421 params,
422 resultFormatCodes);
423 Portal oldPortal = portals.put(portalName, portal);
424 if (oldPortal != null) {
425 // According to the wire protocol spec named portals should be removed explicitly and only
426 // unnamed portals are implicitly closed/overridden.
427 // We don't comply with the spec because we allow batching of statements, see #execute
428 oldPortal.closeActiveConsumer();
429 }
430
431 // Clients might try to describe a declared query, need to store a portal to allow that.
432 if (preparedStmt.analyzedStatement() instanceof AnalyzedDeclare analyzedDeclare) {
433 Declare declare = analyzedDeclare.declare();
434 String cursorName = declare.cursorName();
435 if (!cursorName.equals(portalName)) {
436 var parameterTypes = ParameterTypes.extract(analyzedDeclare.query()).toArray(new DataType[0]);
437 PreparedStmt preparedQuery = new PreparedStmt(
438 declare.query(),
439 analyzedDeclare.query(),
440 SqlFormatter.formatSql(declare.query()),
441 parameterTypes,
442 preparedStmt.timeoutToken()
443 );
444 Portal queryPortal = new Portal(
445 cursorName,
446 preparedQuery,
447 List.of(),
448 resultFormatCodes
449 );
450 portals.put(cursorName, queryPortal);
451 }
452 }
453 }
454
455 public DescribeResult describe(char type, String portalOrStatement) {
456 if (LOGGER.isDebugEnabled()) {

Calls 15

getSafeStmtMethod · 0.95
dirtyUUIDMethod · 0.95
messageOfMethod · 0.95
closeActiveConsumerMethod · 0.95
analyzedStatementMethod · 0.95
cursorNameMethod · 0.95
extractMethod · 0.95
queryMethod · 0.95
formatSqlMethod · 0.95
timeoutTokenMethod · 0.95
sessionUserMethod · 0.80