1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Add extra_float_digits GUC parameter to allow adjustment of displayed

precision for float4, float8, and geometric types.  Set it in pg_dump
so that float data can be dumped/reloaded exactly (at least on platforms
where the float I/O support is properly implemented).  Initial patch by
Pedro Ferreira, some additional work by Tom Lane.
This commit is contained in:
Tom Lane
2002-11-08 17:37:52 +00:00
parent fef731d1c4
commit d2c744aa56
8 changed files with 107 additions and 39 deletions

View File

@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.305 2002/10/22 19:15:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.306 2002/11/08 17:37:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -171,6 +171,7 @@ main(int argc, char **argv)
const char *pgport = NULL;
const char *username = NULL;
bool oids = false;
PGresult *res;
TableInfo *tblinfo;
int numTables;
bool force_password = false;
@@ -549,22 +550,32 @@ main(int argc, char **argv)
/*
* Start serializable transaction to dump consistent data.
*/
res = PQexec(g_conn, "BEGIN");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, NULL, "BEGIN command failed: %s",
PQerrorMessage(g_conn));
PQclear(res);
res = PQexec(g_conn, "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, NULL, "could not set transaction isolation level to serializable: %s",
PQerrorMessage(g_conn));
PQclear(res);
/*
* If supported, set extra_float_digits so that we can dump float data
* exactly (given correctly implemented float I/O code, anyway)
*/
if (g_fout->remoteVersion >= 70400)
{
PGresult *res;
res = PQexec(g_conn, "BEGIN");
res = PQexec(g_conn, "SET extra_float_digits TO 2");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, NULL, "BEGIN command failed: %s",
PQerrorMessage(g_conn));
PQclear(res);
res = PQexec(g_conn, "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, NULL, "could not set transaction isolation level to serializable: %s",
exit_horribly(g_fout, NULL, "could not set extra_float_digits: %s",
PQerrorMessage(g_conn));
PQclear(res);
}
/* Find the last built-in OID, if needed */
if (g_fout->remoteVersion < 70300)
{
if (g_fout->remoteVersion >= 70100)