* Issue SET commands to make sure remote session is configured properly. * * We do this just once at connection, assuming nothing will change the * values later. Since we'll never send volatile function calls to the * remote, there shouldn't be any way to break this assumption from our end. * It's possible to think of ways to break it at the remote end, eg making * a foreign table point to
| 530 | * there are any number of ways to break things. |
| 531 | */ |
| 532 | static void |
| 533 | configure_remote_session(PGconn *conn) |
| 534 | { |
| 535 | int remoteversion = PQserverVersion(conn); |
| 536 | |
| 537 | /* Force the search path to contain only pg_catalog (see deparse.c) */ |
| 538 | do_sql_command(conn, "SET search_path = pg_catalog"); |
| 539 | |
| 540 | /* |
| 541 | * Set remote timezone; this is basically just cosmetic, since all |
| 542 | * transmitted and returned timestamptzs should specify a zone explicitly |
| 543 | * anyway. However it makes the regression test outputs more predictable. |
| 544 | * |
| 545 | * We don't risk setting remote zone equal to ours, since the remote |
| 546 | * server might use a different timezone database. Instead, use UTC |
| 547 | * (quoted, because very old servers are picky about case). |
| 548 | */ |
| 549 | do_sql_command(conn, "SET timezone = 'UTC'"); |
| 550 | |
| 551 | /* |
| 552 | * Set values needed to ensure unambiguous data output from remote. (This |
| 553 | * logic should match what pg_dump does. See also set_transmission_modes |
| 554 | * in postgres_fdw.c.) |
| 555 | */ |
| 556 | do_sql_command(conn, "SET datestyle = ISO"); |
| 557 | if (remoteversion >= 80400) |
| 558 | do_sql_command(conn, "SET intervalstyle = postgres"); |
| 559 | if (remoteversion >= 90000) |
| 560 | do_sql_command(conn, "SET extra_float_digits = 3"); |
| 561 | else |
| 562 | do_sql_command(conn, "SET extra_float_digits = 2"); |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | * Convenience subroutine to issue a non-data-returning SQL command to remote |
no test coverage detected