Re: pg_dump tries to do too much per query

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: pg_dump tries to do too much per query
Date: 2000-09-18 12:18:19
Message-ID: 3.0.5.32.20000918221819.029c2b00@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 16:29 17/09/00 -0400, Tom Lane wrote:
>
>create table test (f1 int);
>create view v_test as select f1+1 as f11 from test;
>drop table test;
>
>then run pg_dump:
>
>getTables(): SELECT failed. Explanation from backend: 'ERROR: cache
lookup of attribute 1 in relation 400384 failed
>'.
>

FWIW, the patch below causes get_viewdef to produce:

ERROR: pg_get_viewdef: cache lookup of attribute 1 in relation 19136
failed for rule v_test

when a table has been deleted.

----------------------------------------------------
--- ruleutils.c.orig Wed Sep 13 22:08:04 2000
+++ ruleutils.c Mon Sep 18 20:59:25 2000
@@ -72,6 +72,7 @@
* ----------
*/
static char *rulename = NULL;
+static char *toproutinename = NULL;
static void *plan_getrule = NULL;
static char *query_getrule = "SELECT * FROM pg_rewrite WHERE rulename = $1";
static void *plan_getview = NULL;
@@ -134,6 +135,12 @@
int len;

/* ----------
+ * We use this in reporting errors.
+ * ----------
+ */
+ toproutinename = "pg_get_ruledef";
+
+ /* ----------
* We need the rules name somewhere deep down: rulename is global
* ----------
*/
@@ -234,6 +241,12 @@
char *name;

/* ----------
+ * We use this in reporting errors.
+ * ----------
+ */
+ toproutinename = "pg_get_viewdef";
+
+ /* ----------
* We need the view name somewhere deep down
* ----------
*/
@@ -337,6 +350,13 @@
char *sep;

/* ----------
+ * We use this in reporting errors.
+ * ----------
+ */
+ toproutinename = "pg_get_indexdef";
+ rulename = NULL;
+
+ /* ----------
* Connect to SPI manager
* ----------
*/
@@ -554,6 +574,13 @@
Form_pg_shadow user_rec;

/* ----------
+ * We use this in reporting errors.
+ * ----------
+ */
+ toproutinename = "pg_get_userbyid";
+ rulename = NULL;
+
+ /* ----------
* Allocate space for the result
* ----------
*/
@@ -2014,8 +2041,16 @@
ObjectIdGetDatum(relid), (Datum) attnum,
0, 0);
if (!HeapTupleIsValid(atttup))
- elog(ERROR, "cache lookup of attribute %d in relation %u failed",
- attnum, relid);
+ {
+ if (rulename != NULL)
+ {
+ elog(ERROR, "%s: cache lookup of attribute %d in relation %u failed for
rule %s",
+ toproutinename, attnum, relid, rulename);
+ } else {
+ elog(ERROR, "%s: cache lookup of attribute %d in relation %u failed",
+ toproutinename, attnum, relid);
+ }
+ }

attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
return pstrdup(NameStr(attStruct->attname));

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message g.p.ciceri 2000-09-18 14:23:29 contrib module soundex in CVS snapshot (function returning text and TOAST ???)
Previous Message Karl F. Larsen 2000-09-18 11:32:19 Re: Cannot compile