*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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_delhilowstats(Oid relid, int attcnt, int *attnums);
-static void vc_setpagelock(Relation rel, BlockNumber blkno);
static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl);
static void vc_reappage(VPageList vpl, VPageDescr vpc);
static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
* 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
* 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
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
pfree(ctup);
/* overwrite the existing statistics in the tuple */
- vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
pgcform->reltuples = num_tuples;
pgcform->relpages = num_pages;
/* overwrite the existing statistics in the tuple */
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 ||
(stats->null_cnt <= 1 && stats->best_cnt == 1))
selratio = 0;
* Invalidate the cache for the tuple and write the buffer
*/
RelationInvalidateHeapTuple(ad, atup);
- WriteNoReleaseBuffer(abuffer);
+ WriteNoReleaseBuffer(scan->rs_cbuf);
/* DO PG_STATISTIC INSERTS */
*/
RelationInvalidateHeapTuple(rd, &rtup);
- WriteNoReleaseBuffer(buffer);
-
- ReleaseBuffer(buffer);
+ WriteBuffer(buffer);
heap_close(rd);
}
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.
*
*
*
* 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
*
int ntups;
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 "
"where pg_class.oid = ev_class "
"and pg_rewrite.ev_type = '1' "
ntups = PQntuples(res);
- PQclear(res);
- res = PQexec(g_conn, "end");
PQclear(res);
return ntups > 0 ? TRUE : FALSE;
}
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();
if (oids == true)
int i_typbyval;
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 */
/*
PQclear(res);
- res = PQexec(g_conn, "end");
- PQclear(res);
-
return tinfo;
}
* find all operators, including builtin operators, filter out
* 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, "
"oprleft, oprright, oprcom, oprnegate, oprrest, oprjoin, "
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
}
- PQclear(res);
- res = PQexec(g_conn, "end");
PQclear(res);
return oprinfo;
/* 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,
"SELECT pg_aggregate.oid, aggname, aggtransfn1, aggtransfn2, "
"aggfinalfn, aggtranstype1, aggbasetype, aggtranstype2, "
PQclear(res);
- res = PQexec(g_conn, "end");
- PQclear(res);
return agginfo;
}
/* 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,
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
"proretset, proargtypes, prosrc, probin, usename "
finfo[i].dumped = 0;
}
- PQclear(res);
- res = PQexec(g_conn, "end");
PQclear(res);
return finfo;
* 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,
"SELECT pg_class.oid, relname, relkind, relacl, usename, "
"relchecks, reltriggers "
tblinfo[i].triggers = NULL;
}
- PQclear(res);
- res = PQexec(g_conn, "end");
PQclear(res);
return tblinfo;
int i_inhparent;
/* 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");
inhinfo[i].inhparent = strdup(PQgetvalue(res, i, i_inhparent));
}
- PQclear(res);
- res = PQexec(g_conn, "end");
PQclear(res);
return inhinfo;
}
* 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,
"SELECT t1.relname as indexrelname, t2.relname as indrelname, "
"i.indproc, i.indkey, i.indclass, "
indinfo[i].indisunique = strdup(PQgetvalue(res, i, i_indisunique));
}
PQclear(res);
- res = PQexec(g_conn, "end");
- PQclear(res);
return indinfo;
}
int i,
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 "
"WHERE lanispl "
"ORDER BY oid");
PQclear(res);
- res = PQexec(g_conn, "end");
- PQclear(res);
}
/*
int i_lanname;
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 "
"WHERE oid = %u",
finfo[i].lang);
PQclear(res);
- res = PQexec(g_conn, "end");
- PQclear(res);
}
if (dropSchema)
{
if (tablename && strcmp(tblinfo[t].relname, tablename))
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
fprintf(fout, "%s\n", PQgetvalue(res, i, i_definition));
PQclear(res);
-
- res = PQexec(g_conn, "end");
- PQclear(res);
}
}