(self, db, pub_connstr)
Look if public and local connect strings point to same db's.
Look if public and local connect strings point to same db's.
Look if public and local connect strings point to same db s .
def check_public_connstr(self, db, pub_connstr):
        """Look if public and local connect strings point to same db's.
        """
        pub_db = self.get_database("pub_db", connstr = pub_connstr, profile = 'remote')
        curs1 = db.cursor()
        curs2 = pub_db.cursor()
        q = "select oid, datname, txid_current() as txid, txid_current_snapshot() as snap"\
            " from pg_catalog.pg_database where datname = current_database()"
        curs1.execute(q)
        res1 = curs1.fetchone()
        db.commit()

        curs2.execute(q)
        res2 = curs2.fetchone()
        pub_db.commit()

        curs1.execute(q)
        res3 = curs1.fetchone()
        db.commit()

        self.close_database("pub_db")

        failure = 0
        if (res1['oid'], res1['datname']) != (res2['oid'], res2['datname']):
            failure += 1

        sn1 = skytools.Snapshot(res1['snap'])
        tx = res2['txid']
        sn2 = skytools.Snapshot(res3['snap'])
        if sn1.contains(tx):
            failure += 2
        elif not sn2.contains(tx):
            failure += 4

        if failure:
            raise UsageError("Public connect string points to different database than local connect string (fail=%d)" % failure)
def check_public_connstr ( self , db , pub_connstr ) : pub_db = self . get_database ( "pub_db" , connstr = pub_connstr , profile = 'remote' ) curs1 = db . cursor ( ) curs2 = pub_db . cursor ( ) q = "select oid, datname, txid_current() as txid, txid_current_snapshot() as snap" " from pg_catalog.pg_database where datname = current_database()" curs1 . execute ( q ) res1 = curs1 . fetchone ( ) db . commit ( ) curs2 . execute ( q ) res2 = curs2 . fetchone ( ) pub_db . commit ( ) curs1 . execute ( q ) res3 = curs1 . fetchone ( ) db . commit ( ) self . close_database ( "pub_db" ) failure = 0 if ( res1 [ 'oid' ] , res1 [ 'datname' ] ) != ( res2 [ 'oid' ] , res2 [ 'datname' ] ) : failure += 1 sn1 = skytools . Snapshot ( res1 [ 'snap' ] ) tx = res2 [ 'txid' ] sn2 = skytools . Snapshot ( res3 [ 'snap' ] ) if sn1 . contains ( tx ) : failure += 2 elif not sn2 . contains ( tx ) : failure += 4 if failure : raise UsageError ( "Public connect string points to different database than local connect string (fail=%d)" % failure )