Produce a somewhat-useful error message, namely
authorTom Lane
Thu, 29 Aug 2002 04:38:04 +0000 (04:38 +0000)
committerTom Lane
Thu, 29 Aug 2002 04:38:04 +0000 (04:38 +0000)
ERROR:  Cannot display a value of type RECORD
rather than a random integer when someone tries to SELECT a tuple
value.  Per pghackers discussion around 26-May-02.

src/backend/catalog/heap.c
src/include/catalog/pg_type.h

index c768ca2d55475a2348456f7513527219a471aad4..faea56df47c51d3e0ad44ac2d6d42d6a652f6ecb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.222 2002/08/29 00:17:02 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.223 2002/08/29 04:38:04 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -623,6 +623,12 @@ AddNewRelationType(const char *typeName,
                   Oid new_type_oid)
 {
    /*
+    * We set the I/O procedures of a complex type to record_in and
+    * record_out, so that a user will get an error message not a weird
+    * number if he tries to SELECT a complex type.
+    *
+    * OLD and probably obsolete comments:
+    *
     * The sizes are set to oid size because it makes implementing sets
     * MUCH easier, and no one (we hope) uses these fields to figure out
     * how much space to allocate for the type. An oid is the type used
@@ -639,8 +645,8 @@ AddNewRelationType(const char *typeName,
               sizeof(Oid),     /* internal size */
               'c',             /* type-type (complex) */
               ',',             /* default array delimiter */
-              F_OIDIN,         /* input procedure */
-              F_OIDOUT,        /* output procedure */
+              F_RECORD_IN,     /* input procedure */
+              F_RECORD_OUT,    /* output procedure */
               InvalidOid,      /* array element type - irrelevant */
               InvalidOid,      /* domain base type - irrelevant */
               NULL,            /* default type value - none */
index 3708a71bab9ede8646fc85c2ff3c59f87523cff4..5b4e15c5595c0bb8c7bdc01e86e63bac33c5e7e4 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_type.h,v 1.131 2002/08/29 00:17:06 tgl Exp $
+ * $Id: pg_type.h,v 1.132 2002/08/29 04:38:04 tgl Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -296,13 +296,13 @@ DESCR("array of INDEX_MAX_KEYS oids, used in system tables");
 DATA(insert OID = 32 ( SET        PGNSP PGUID -1 f b t \054 0   0 unknownin unknownout i p f 0 -1 0 _null_ _null_ ));
 DESCR("set of tuples");
 
-DATA(insert OID = 71 ( pg_type      PGNSP PGUID 4 t c t \054 1247 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 75 ( pg_attribute PGNSP PGUID 4 t c t \054 1249 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 81 ( pg_proc      PGNSP PGUID 4 t c t \054 1255 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 83 ( pg_class     PGNSP PGUID 4 t c t \054 1259 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 86 ( pg_shadow    PGNSP PGUID 4 t c t \054 1260 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 87 ( pg_group     PGNSP PGUID 4 t c t \054 1261 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
-DATA(insert OID = 88 ( pg_database  PGNSP PGUID 4 t c t \054 1262 0 int4in int4out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 71 ( pg_type      PGNSP PGUID 4 t c t \054 1247 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 75 ( pg_attribute PGNSP PGUID 4 t c t \054 1249 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 81 ( pg_proc      PGNSP PGUID 4 t c t \054 1255 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 83 ( pg_class     PGNSP PGUID 4 t c t \054 1259 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 86 ( pg_shadow    PGNSP PGUID 4 t c t \054 1260 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 87 ( pg_group     PGNSP PGUID 4 t c t \054 1261 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 88 ( pg_database  PGNSP PGUID 4 t c t \054 1262 0 record_in record_out i p f 0 -1 0 _null_ _null_ ));
 
 /* OIDS 100 - 199 */