aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-06-06 16:50:37 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-06-06 16:50:37 +0000
commit05cd91a5825f89a624fc6335b6c337c8e6d77583 (patch)
tree676436565b522735f329e71e32304ade6fc3ad69 /src
parent4032a515d26eb2772c0f929db1dd8c38fcab3f92 (diff)
downloadpostgresql-05cd91a5825f89a624fc6335b6c337c8e6d77583.tar.gz
postgresql-05cd91a5825f89a624fc6335b6c337c8e6d77583.zip
typeTypeName() must return a pstrdup'd copy of the type name, not a
direct pointer into the syscache entry for the type. In some cases the syscache entry might get flushed before we are done using the returned type name. This bug accounts for difficult-to-repeat failures seen when INSERTs into columns of certain data types are run in parallel with VACUUMs of system tables. There may be related problems elsewhere --- we need to take a harder look at uses of syscache data.
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/parse_type.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index ac4f94ec957..69037338428 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.30 2000/05/30 04:24:49 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.31 2000/06/06 16:50:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,8 @@ typeidTypeName(Oid id)
return NULL;
}
typetuple = (Form_pg_type) GETSTRUCT(tup);
- return NameStr(typetuple->typname);
+ /* pstrdup here because result may need to outlive the syscache entry */
+ return pstrdup(NameStr(typetuple->typname));
}
/* return a Type structure, given a type id */
@@ -119,7 +120,8 @@ typeTypeName(Type t)
Form_pg_type typ;
typ = (Form_pg_type) GETSTRUCT(t);
- return NameStr(typ->typname);
+ /* pstrdup here because result may need to outlive the syscache entry */
+ return pstrdup(NameStr(typ->typname));
}
/* given a type, return its typetype ('c' for 'c'atalog types) */