contrib/postgres_fdw/connection.c
static void
begin_remote_xact(ConnCacheEntry *entry)
{
	int			curlevel = GetCurrentTransactionNestLevel();

	/* Start main transaction if we haven't yet */
	if (entry->xact_depth <= 0)
	{
		const char *sql;

		elog(DEBUG3, "starting remote transaction on connection %p",
			 entry->conn);

		if (IsolationIsSerializable())
			sql = "START TRANSACTION ISOLATION LEVEL SERIALIZABLE";
		else
			sql = "START TRANSACTION ISOLATION LEVEL REPEATABLE READ";
		do_sql_command(entry->conn, sql);
		entry->xact_depth = 1;
	}

	/*
	 * If we're in a subtransaction, stack up savepoints to match our level.
	 * This ensures we can rollback just the desired effects when a
	 * subtransaction aborts.
	 */
	while (entry->xact_depth < curlevel)
	{
		char		sql[64];

		snprintf(sql, sizeof(sql), "SAVEPOINT s%d", entry->xact_depth + 1);
		do_sql_command(entry->conn, sql);
		entry->xact_depth++;
	}
}
/*
 * Start remote transaction or subtransaction, if needed.
 *
 * Note that we always use at least REPEATABLE READ in the remote session.
 * This is so that, if a query initiates multiple scans of the same or
 * different foreign tables, we will get snapshot-consistent results from
 * those scans.  A disadvantage is that we can't provide sane emulation of
 * READ COMMITTED behavior --- it would be nice if we had some other way to
 * control which remote queries share a snapshot.
 */
Start remote transaction or subtransaction, if needed.
Note that we always use at least REPEATABLE READ in the remote session.
This is so that, if a query initiates multiple scans of the same or
different foreign tables, we will get snapshot-consistent results from
those scans.  A disadvantage is that we can't provide sane emulation of
READ COMMITTED behavior --- it would be nice if we had some other way to
control which remote queries share a snapshot.
Start remote transaction or subtransaction if needed . Note that we always use at least REPEATABLE READ in the remote session . This is so that if a query initiates multiple scans of the same or different foreign tables we will get snapshot - consistent results from those scans . A disadvantage is that we can ' t provide sane emulation of READ COMMITTED behavior --- it would be nice if we had some other way to control which remote queries share a snapshot .
static void
begin_remote_xact(ConnCacheEntry *entry)
{
	int			curlevel = GetCurrentTransactionNestLevel();
	if (entry->xact_depth <= 0)
	{
		const char *sql;
		elog(DEBUG3, "starting remote transaction on connection %p",
			 entry->conn);
		if (IsolationIsSerializable())
			sql = "START TRANSACTION ISOLATION LEVEL SERIALIZABLE";
		else
			sql = "START TRANSACTION ISOLATION LEVEL REPEATABLE READ";
		do_sql_command(entry->conn, sql);
		entry->xact_depth = 1;
	}
	while (entry->xact_depth < curlevel)
	{
		char		sql[64];
		snprintf(sql, sizeof(sql), "SAVEPOINT s%d", entry->xact_depth + 1);
		do_sql_command(entry->conn, sql);
		entry->xact_depth++;
	}
}
static void begin_remote_xact ( ConnCacheEntry * entry ) { int curlevel = GetCurrentTransactionNestLevel ( ) ; if ( entry -> xact_depth <= 0 ) { const char * sql ; elog ( DEBUG3 , " " , entry -> conn ) ; if ( IsolationIsSerializable ( ) ) sql = " " ; else sql = " " ; do_sql_command ( entry -> conn , sql ) ; entry -> xact_depth = 1 ; } while ( entry -> xact_depth < curlevel ) { char sql [ 64 ] ; snprintf ( sql , sizeof ( sql ) , " " , entry -> xact_depth + 1 ) ; do_sql_command ( entry -> conn , sql ) ; entry -> xact_depth ++ ; } }
Start remote transaction or subtransaction, if needed.
Start remote transaction or subtransaction if needed .
/* Start main transaction if we haven't yet */ /*
	 * If we're in a subtransaction, stack up savepoints to match our level.
	 * This ensures we can rollback just the desired effects when a
	 * subtransaction aborts.
	 */