// open database and set status -- first time only
 bool Open(PostgresConnect dbhandle)
 {
     _dbhandle = dbhandle;
     _connectstack.Push(new OpenState());
     SetError(SpiReturn.OK, "");
     IsOpen = CheckOk();
     return(CheckOk());
 }
        //-------------------------------------------------------------------------
        // Create a new instance of PG connection and interop
        public static PostgresConnect Create(IExecuteGateway gateway, PostgresDatabase database)
        {
            var pgd = new PostgresConnect()
            {
                _gateway  = gateway,
                _database = database,
            };

            // the initial functions; more will be added, to mirror the catalog
            pgd.AddFunctions();
            return(pgd);
        }