mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
1. Run all pg_dump queries in single serializable transaction.
2. Get rid of locking when updating statistics in vacuum. 3. Use QuerySnapshot in COPY TO and call SetQuerySnashot in main tcop loop before FETCH and COPY TO.
This commit is contained in:
parent
bbbc211ed1
commit
df9e539ea2
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.78 1999/05/26 12:55:10 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.79 1999/05/29 10:25:29 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -381,7 +381,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
|||||||
int32 ntuples;
|
int32 ntuples;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
scandesc = heap_beginscan(rel, 0, SnapshotNow, 0, NULL);
|
scandesc = heap_beginscan(rel, 0, QuerySnapshot, 0, NULL);
|
||||||
|
|
||||||
attr_count = rel->rd_att->natts;
|
attr_count = rel->rd_att->natts;
|
||||||
attr = rel->rd_att->attrs;
|
attr = rel->rd_att->attrs;
|
||||||
@ -1363,7 +1363,7 @@ CountTuples(Relation relation)
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
scandesc = heap_beginscan(relation, 0, SnapshotNow, 0, NULL);
|
scandesc = heap_beginscan(relation, 0, QuerySnapshot, 0, NULL);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
|
while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.104 1999/05/25 16:08:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.105 1999/05/29 10:25:30 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -93,7 +93,6 @@ static void vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple tupl
|
|||||||
static void vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_len);
|
static void vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_len);
|
||||||
static void vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats);
|
static void vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats);
|
||||||
static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
|
static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
|
||||||
static void vc_setpagelock(Relation rel, BlockNumber blkno);
|
|
||||||
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
|
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
|
||||||
static void vc_reappage(VPageList vpl, VPageDescr vpc);
|
static void vc_reappage(VPageList vpl, VPageDescr vpc);
|
||||||
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
||||||
@ -2221,7 +2220,8 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
|
|||||||
* tuple that's already on the page. The reason for this is that if
|
* tuple that's already on the page. The reason for this is that if
|
||||||
* we updated these tuples in the usual way, then every tuple in pg_class
|
* we updated these tuples in the usual way, then every tuple in pg_class
|
||||||
* would be replaced every day. This would make planning and executing
|
* would be replaced every day. This would make planning and executing
|
||||||
* historical queries very expensive.
|
* historical queries very expensive. Note that we also don't use
|
||||||
|
* any locking while doing updation.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
|
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
|
||||||
@ -2257,7 +2257,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
pfree(ctup);
|
pfree(ctup);
|
||||||
|
|
||||||
/* overwrite the existing statistics in the tuple */
|
/* overwrite the existing statistics in the tuple */
|
||||||
vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
|
|
||||||
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
|
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
|
||||||
pgcform->reltuples = num_tuples;
|
pgcform->reltuples = num_tuples;
|
||||||
pgcform->relpages = num_pages;
|
pgcform->relpages = num_pages;
|
||||||
@ -2301,11 +2300,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
/* overwrite the existing statistics in the tuple */
|
/* overwrite the existing statistics in the tuple */
|
||||||
if (VacAttrStatsEqValid(stats))
|
if (VacAttrStatsEqValid(stats))
|
||||||
{
|
{
|
||||||
Buffer abuffer = scan->rs_cbuf;
|
|
||||||
|
|
||||||
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_self));
|
|
||||||
attp = (Form_pg_attribute) GETSTRUCT(atup);
|
|
||||||
|
|
||||||
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
||||||
(stats->null_cnt <= 1 && stats->best_cnt == 1))
|
(stats->null_cnt <= 1 && stats->best_cnt == 1))
|
||||||
selratio = 0;
|
selratio = 0;
|
||||||
@ -2338,7 +2332,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
* Invalidate the cache for the tuple and write the buffer
|
* Invalidate the cache for the tuple and write the buffer
|
||||||
*/
|
*/
|
||||||
RelationInvalidateHeapTuple(ad, atup);
|
RelationInvalidateHeapTuple(ad, atup);
|
||||||
WriteNoReleaseBuffer(abuffer);
|
WriteNoReleaseBuffer(scan->rs_cbuf);
|
||||||
|
|
||||||
/* DO PG_STATISTIC INSERTS */
|
/* DO PG_STATISTIC INSERTS */
|
||||||
|
|
||||||
@ -2396,9 +2390,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
|||||||
*/
|
*/
|
||||||
RelationInvalidateHeapTuple(rd, &rtup);
|
RelationInvalidateHeapTuple(rd, &rtup);
|
||||||
|
|
||||||
WriteNoReleaseBuffer(buffer);
|
WriteBuffer(buffer);
|
||||||
|
|
||||||
ReleaseBuffer(buffer);
|
|
||||||
|
|
||||||
heap_close(rd);
|
heap_close(rd);
|
||||||
}
|
}
|
||||||
@ -2449,12 +2441,6 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
|||||||
heap_close(pgstatistic);
|
heap_close(pgstatistic);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
vc_setpagelock(Relation rel, BlockNumber blkno)
|
|
||||||
{
|
|
||||||
LockPage(rel, blkno, ExclusiveLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vc_reappage() -- save a page on the array of reapped pages.
|
* vc_reappage() -- save a page on the array of reapped pages.
|
||||||
*
|
*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.117 1999/05/26 12:55:55 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.118 1999/05/29 10:25:30 vadim Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
@ -73,6 +73,8 @@
|
|||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/ps_status.h"
|
#include "utils/ps_status.h"
|
||||||
#include "utils/temprel.h"
|
#include "utils/temprel.h"
|
||||||
|
#include "nodes/parsenodes.h"
|
||||||
|
#include "../backend/parser/parse.h"
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
@ -715,6 +717,13 @@ pg_exec_query_dest(char *query_string, /* string to execute */
|
|||||||
else if (Verbose)
|
else if (Verbose)
|
||||||
TPRINTF(TRACE_VERBOSE, "ProcessUtility");
|
TPRINTF(TRACE_VERBOSE, "ProcessUtility");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have to set query SnapShot in the case of FETCH or COPY TO.
|
||||||
|
*/
|
||||||
|
if (nodeTag(querytree->utilityStmt) == T_FetchStmt ||
|
||||||
|
(nodeTag(querytree->utilityStmt) == T_CopyStmt &&
|
||||||
|
((CopyStmt *)(querytree->utilityStmt))->direction != FROM))
|
||||||
|
SetQuerySnapshot();
|
||||||
ProcessUtility(querytree->utilityStmt, dest);
|
ProcessUtility(querytree->utilityStmt, dest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1527,7 +1536,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
|||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface ");
|
puts("\nPOSTGRES backend interactive interface ");
|
||||||
puts("$Revision: 1.117 $ $Date: 1999/05/26 12:55:55 $\n");
|
puts("$Revision: 1.118 $ $Date: 1999/05/29 10:25:30 $\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.113 1999/05/27 16:29:03 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.114 1999/05/29 10:25:31 vadim Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -190,15 +190,6 @@ isViewRule(char *relname)
|
|||||||
int ntups;
|
int ntups;
|
||||||
char query[MAX_QUERY_SIZE];
|
char query[MAX_QUERY_SIZE];
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query, "select relname from pg_class, pg_rewrite "
|
sprintf(query, "select relname from pg_class, pg_rewrite "
|
||||||
"where pg_class.oid = ev_class "
|
"where pg_class.oid = ev_class "
|
||||||
"and pg_rewrite.ev_type = '1' "
|
"and pg_rewrite.ev_type = '1' "
|
||||||
@ -214,8 +205,6 @@ isViewRule(char *relname)
|
|||||||
|
|
||||||
ntups = PQntuples(res);
|
ntups = PQntuples(res);
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
return ntups > 0 ? TRUE : FALSE;
|
return ntups > 0 ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
@ -722,6 +711,28 @@ main(int argc, char **argv)
|
|||||||
exit_nicely(g_conn);
|
exit_nicely(g_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start serializable transaction to dump consistent data
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PGresult *res;
|
||||||
|
|
||||||
|
res = PQexec(g_conn, "begin");
|
||||||
|
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
||||||
|
exit_nicely(g_conn);
|
||||||
|
}
|
||||||
|
PQclear(res);
|
||||||
|
res = PQexec(g_conn, "set transaction isolation level serializable");
|
||||||
|
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "SET TRANSACTION command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
||||||
|
exit_nicely(g_conn);
|
||||||
|
}
|
||||||
|
PQclear(res);
|
||||||
|
}
|
||||||
|
|
||||||
g_last_builtin_oid = findLastBuiltinOid();
|
g_last_builtin_oid = findLastBuiltinOid();
|
||||||
|
|
||||||
if (oids == true)
|
if (oids == true)
|
||||||
@ -789,15 +800,6 @@ getTypes(int *numTypes)
|
|||||||
int i_typbyval;
|
int i_typbyval;
|
||||||
int i_usename;
|
int i_usename;
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
/* find all base types */
|
/* find all base types */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -878,9 +880,6 @@ getTypes(int *numTypes)
|
|||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return tinfo;
|
return tinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,14 +921,6 @@ getOperators(int *numOprs)
|
|||||||
* find all operators, including builtin operators, filter out
|
* find all operators, including builtin operators, filter out
|
||||||
* system-defined operators at dump-out time
|
* system-defined operators at dump-out time
|
||||||
*/
|
*/
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query, "SELECT pg_operator.oid, oprname, oprkind, oprcode, "
|
sprintf(query, "SELECT pg_operator.oid, oprname, oprkind, oprcode, "
|
||||||
"oprleft, oprright, oprcom, oprnegate, oprrest, oprjoin, "
|
"oprleft, oprright, oprcom, oprnegate, oprrest, oprjoin, "
|
||||||
@ -983,8 +974,6 @@ getOperators(int *numOprs)
|
|||||||
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
|
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return oprinfo;
|
return oprinfo;
|
||||||
@ -1259,15 +1248,6 @@ getAggregates(int *numAggs)
|
|||||||
|
|
||||||
/* find all user-defined aggregates */
|
/* find all user-defined aggregates */
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query,
|
sprintf(query,
|
||||||
"SELECT pg_aggregate.oid, aggname, aggtransfn1, aggtransfn2, "
|
"SELECT pg_aggregate.oid, aggname, aggtransfn1, aggtransfn2, "
|
||||||
"aggfinalfn, aggtranstype1, aggbasetype, aggtranstype2, "
|
"aggfinalfn, aggtranstype1, aggbasetype, aggtranstype2, "
|
||||||
@ -1316,8 +1296,6 @@ getAggregates(int *numAggs)
|
|||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
return agginfo;
|
return agginfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1352,15 +1330,6 @@ getFuncs(int *numFuncs)
|
|||||||
|
|
||||||
/* find all user-defined funcs */
|
/* find all user-defined funcs */
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query,
|
sprintf(query,
|
||||||
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
|
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
|
||||||
"proretset, proargtypes, prosrc, probin, usename "
|
"proretset, proargtypes, prosrc, probin, usename "
|
||||||
@ -1413,8 +1382,6 @@ getFuncs(int *numFuncs)
|
|||||||
finfo[i].dumped = 0;
|
finfo[i].dumped = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return finfo;
|
return finfo;
|
||||||
@ -1455,15 +1422,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
|
|||||||
* we ignore tables that start with xinv
|
* we ignore tables that start with xinv
|
||||||
*/
|
*/
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query,
|
sprintf(query,
|
||||||
"SELECT pg_class.oid, relname, relkind, relacl, usename, "
|
"SELECT pg_class.oid, relname, relkind, relacl, usename, "
|
||||||
"relchecks, reltriggers "
|
"relchecks, reltriggers "
|
||||||
@ -1759,8 +1717,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
|
|||||||
tblinfo[i].triggers = NULL;
|
tblinfo[i].triggers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return tblinfo;
|
return tblinfo;
|
||||||
@ -1789,14 +1745,6 @@ getInherits(int *numInherits)
|
|||||||
int i_inhparent;
|
int i_inhparent;
|
||||||
|
|
||||||
/* find all the inheritance information */
|
/* find all the inheritance information */
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query, "SELECT inhrel, inhparent from pg_inherits");
|
sprintf(query, "SELECT inhrel, inhparent from pg_inherits");
|
||||||
|
|
||||||
@ -1823,8 +1771,6 @@ getInherits(int *numInherits)
|
|||||||
inhinfo[i].inhparent = strdup(PQgetvalue(res, i, i_inhparent));
|
inhinfo[i].inhparent = strdup(PQgetvalue(res, i, i_inhparent));
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
return inhinfo;
|
return inhinfo;
|
||||||
}
|
}
|
||||||
@ -1977,15 +1923,6 @@ getIndices(int *numIndices)
|
|||||||
* this is a 4-way join !!
|
* this is a 4-way join !!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query,
|
sprintf(query,
|
||||||
"SELECT t1.relname as indexrelname, t2.relname as indrelname, "
|
"SELECT t1.relname as indexrelname, t2.relname as indrelname, "
|
||||||
"i.indproc, i.indkey, i.indclass, "
|
"i.indproc, i.indkey, i.indclass, "
|
||||||
@ -2031,8 +1968,6 @@ getIndices(int *numIndices)
|
|||||||
indinfo[i].indisunique = strdup(PQgetvalue(res, i, i_indisunique));
|
indinfo[i].indisunique = strdup(PQgetvalue(res, i, i_indisunique));
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
return indinfo;
|
return indinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2138,14 +2073,6 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
|
|||||||
int i,
|
int i,
|
||||||
fidx;
|
fidx;
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(query, "SELECT * FROM pg_language "
|
sprintf(query, "SELECT * FROM pg_language "
|
||||||
"WHERE lanispl "
|
"WHERE lanispl "
|
||||||
"ORDER BY oid");
|
"ORDER BY oid");
|
||||||
@ -2198,8 +2125,6 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
|
|||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2262,15 +2187,6 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
|
|||||||
int i_lanname;
|
int i_lanname;
|
||||||
char query[256];
|
char query[256];
|
||||||
|
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "dumpOneFunc(): BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
sprintf(query, "SELECT lanname FROM pg_language "
|
sprintf(query, "SELECT lanname FROM pg_language "
|
||||||
"WHERE oid = %u",
|
"WHERE oid = %u",
|
||||||
finfo[i].lang);
|
finfo[i].lang);
|
||||||
@ -2296,8 +2212,6 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
|
|||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropSchema)
|
if (dropSchema)
|
||||||
@ -3330,14 +3244,6 @@ dumpRules(FILE *fout, const char *tablename,
|
|||||||
{
|
{
|
||||||
if (tablename && strcmp(tblinfo[t].relname, tablename))
|
if (tablename && strcmp(tblinfo[t].relname, tablename))
|
||||||
continue;
|
continue;
|
||||||
res = PQexec(g_conn, "begin");
|
|
||||||
if (!res ||
|
|
||||||
PQresultStatus(res) != PGRES_COMMAND_OK)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get all rules defined for this table
|
* Get all rules defined for this table
|
||||||
@ -3367,9 +3273,6 @@ dumpRules(FILE *fout, const char *tablename,
|
|||||||
fprintf(fout, "%s\n", PQgetvalue(res, i, i_definition));
|
fprintf(fout, "%s\n", PQgetvalue(res, i, i_definition));
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
res = PQexec(g_conn, "end");
|
|
||||||
PQclear(res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user