Class PgServer

java.lang.Object
org.h2.server.pg.PgServer
All Implemented Interfaces:
Service

public class PgServer extends Object implements Service
This class implements a subset of the PostgreSQL protocol as described here: https://www.postgresql.org/docs/devel/protocol.html The PostgreSQL catalog is described here: https://www.postgresql.org/docs/7.4/catalogs.html
  • Field Details

  • Constructor Details

    • PgServer

      public PgServer()
  • Method Details

    • init

      public void init(String... args)
      Description copied from interface: Service
      Initialize the service from command line options.
      Specified by:
      init in interface Service
      Parameters:
      args - the command line options
    • getTrace

      boolean getTrace()
    • trace

      void trace(String s)
      Print a message if the trace flag is enabled.
      Parameters:
      s - the message
    • remove

      void remove(PgServerThread t)
      Remove a thread from the list.
      Parameters:
      t - the thread to remove
    • traceError

      void traceError(Exception e)
      Print the stack trace if the trace flag is enabled.
      Parameters:
      e - the exception
    • getURL

      public String getURL()
      Description copied from interface: Service
      Get the URL of this service in a human readable form
      Specified by:
      getURL in interface Service
      Returns:
      the url
    • getPort

      public int getPort()
      Description copied from interface: Service
      Gets the port this service is listening on.
      Specified by:
      getPort in interface Service
      Returns:
      the port
    • allow

      private boolean allow(Socket socket)
    • start

      public void start()
      Description copied from interface: Service
      Start the service. This usually means create the server socket. This method must not block.
      Specified by:
      start in interface Service
    • listen

      public void listen()
      Description copied from interface: Service
      Listen for incoming connections. This method blocks.
      Specified by:
      listen in interface Service
    • stop

      public void stop()
      Description copied from interface: Service
      Stop the service.
      Specified by:
      stop in interface Service
    • isRunning

      public boolean isRunning(boolean traceError)
      Description copied from interface: Service
      Check if the service is running.
      Specified by:
      isRunning in interface Service
      Parameters:
      traceError - if errors should be written
      Returns:
      if the server is running
    • getThread

      PgServerThread getThread(int processId)
      Get the thread with the given process id.
      Parameters:
      processId - the process id
      Returns:
      the thread
    • getBaseDir

      String getBaseDir()
    • getAllowOthers

      public boolean getAllowOthers()
      Description copied from interface: Service
      Check if remote connections are allowed.
      Specified by:
      getAllowOthers in interface Service
      Returns:
      true if remote connections are allowed
    • getType

      public String getType()
      Description copied from interface: Service
      Get the human readable short name of the service.
      Specified by:
      getType in interface Service
      Returns:
      the type
    • getName

      public String getName()
      Description copied from interface: Service
      Get the human readable name of the service.
      Specified by:
      getName in interface Service
      Returns:
      the name
    • getIfExists

      boolean getIfExists()
    • formatType

      public static String formatType(int pgType)
      Returns the name of the given type.
      Parameters:
      pgType - the PostgreSQL type oid
      Returns:
      the name of the given type
    • convertType

      public static int convertType(TypeInfo type)
      Convert the SQL type to a PostgreSQL type
      Parameters:
      type - the SQL type
      Returns:
      the PostgreSQL type
    • getTypeSet

      HashSet<Integer> getTypeSet()
      Get the type hash set.
      Returns:
      the type set
    • checkType

      void checkType(int type)
      Check whether a data type is supported. A warning is logged if not.
      Parameters:
      type - the type
    • checkKeyAndGetDatabaseName

      public String checkKeyAndGetDatabaseName(String db)
      If no key is set, return the original database name. If a key is set, check if the key matches. If yes, return the correct database name. If not, throw an exception.
      Parameters:
      db - the key to test (or database name if no key is used)
      Returns:
      the database name
      Throws:
      DbException - if a key is set but doesn't match
    • isDaemon

      public boolean isDaemon()
      Description copied from interface: Service
      Check if a daemon thread should be used.
      Specified by:
      isDaemon in interface Service
      Returns:
      true if a daemon thread should be used