コード例 #1
0
 @Override
 public PostgresStatementResult execute(
     PostgresQueryContext context, QueryBindings bindings, int maxrows) throws IOException {
   PostgresServerSession server = context.getServer();
   server.getSessionMonitor().countEvent(StatementTypes.OTHER_STMT);
   PostgresMessenger messenger = server.getMessenger();
   ServerValueEncoder encoder = server.getValueEncoder();
   int nrows = 0;
   for (String row : explanation) {
     messenger.beginMessage(PostgresMessages.DATA_ROW_TYPE.code());
     messenger.writeShort(1);
     ByteArrayOutputStream bytes = encoder.encodePObject(row, colType, false);
     messenger.writeInt(bytes.size());
     messenger.writeByteStream(bytes);
     messenger.sendMessage();
     nrows++;
     if ((maxrows > 0) && (nrows >= maxrows)) break;
   }
   return commandComplete("EXPLAIN " + nrows, nrows);
 }
コード例 #2
0
 @Override
 public void sendDescription(PostgresQueryContext context, boolean always, boolean params)
     throws IOException {
   PostgresServerSession server = context.getServer();
   PostgresMessenger messenger = server.getMessenger();
   if (params) {
     messenger.beginMessage(PostgresMessages.PARAMETER_DESCRIPTION_TYPE.code());
     messenger.writeShort(0);
     messenger.sendMessage();
   }
   messenger.beginMessage(PostgresMessages.ROW_DESCRIPTION_TYPE.code());
   messenger.writeShort(1);
   messenger.writeString(colName); // attname
   messenger.writeInt(0); // attrelid
   messenger.writeShort(0); // attnum
   messenger.writeInt(colType.getOid()); // atttypid
   messenger.writeShort(colType.getLength()); // attlen
   messenger.writeInt(colType.getModifier()); // atttypmod
   messenger.writeShort(0);
   messenger.sendMessage();
 }