On Sun, Mar 25, 2007 at 10:18:14PM -0400, Tom Lane wrote:
> David Fetter <[EMAIL PROTECTED]> writes:
> > I've written up a patch intended to implement this on the
> > non-pg_catalog tables and VIEWs, but while it builds, it doesn't
> > initdb.  Enclosed are the patch and the error log.
> > Any hints as to what I might look at?
> 
> > creating template1 database in 
> > /var/lib/pgsql/pgsql/src/test/regress/./tmp_check/data/base/1 ... ok
> > initializing pg_authid ... ok
> > initializing dependencies ... ok
> > creating system views ... ok
> > loading system objects' descriptions ... FATAL:  cache lookup failed for 
> > type 11096
> > child process exited with exit code 1
> 
> That step of initdb creates a TEMP table ... maybe your patch doesn't
> work for temp tables?  Anyway, you're certainly far enough along there
> that you could fire up the postmaster and reproduce the error in a
> normal debugging environment.

I've done that, and thanks to Andrew of Supernews, I've got a slightly
better patch, albeit one that bombs out at the same spot.  In the
patch attached, it appears that TypeCreate is not doing the right
thing in pg_depend, either because I'm not invoking it right or
because it needs more machinery.

Any ideas?

Cheers,
David.
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
Index: src/backend/commands/tablecmds.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/tablecmds.c,v
retrieving revision 1.218
diff -c -r1.218 tablecmds.c
*** src/backend/commands/tablecmds.c    19 Mar 2007 23:38:29 -0000      1.218
--- src/backend/commands/tablecmds.c    27 Mar 2007 17:59:36 -0000
***************
*** 287,298 ****
        Datum           reloptions;
        ListCell   *listptr;
        AttrNumber      attnum;
  
        /*
!        * Truncate relname to appropriate length (probably a waste of time, as
!        * parser should have done this already).
         */
!       StrNCpy(relname, stmt->relation->relname, NAMEDATALEN);
  
        /*
         * Check consistency of arguments
--- 287,310 ----
        Datum           reloptions;
        ListCell   *listptr;
        AttrNumber      attnum;
+       char       *relarrayname;
  
        /*
!        * Truncate relname to appropriate length (probably a waste of time, as 
*
!        * parser should have done this already).  Because tables and views now 
get
!        * an array type, this depends on the relkind.
         */
!       if (
!               namespaceId != 11 && /* pg_catalog's namespace */
!               (relkind == 'r' || relkind == 'v')
!       )
!       {
!               StrNCpy(relname, stmt->relation->relname, NAMEDATALEN-2);
!       }
!       else
!       {
!               StrNCpy(relname, stmt->relation->relname, NAMEDATALEN);
!       }
  
        /*
         * Check consistency of arguments
***************
*** 496,501 ****
--- 508,549 ----
         */
        relation_close(rel, NoLock);
  
+       /*
+        * Add the array type if appropriate.
+        */
+       if (
+               namespaceId != 11 && /* pg_catalog's namespace */
+               (relkind == 'r' || relkind == 'v')
+       )
+       {
+               relarrayname = makeArrayTypeName(relname);
+               TypeCreate(relarrayname,                /* Array type name */
+                                  namespaceId,                 /* Same 
namespace as parent */
+                                  relationId,                  /* relation 
oid, N/A here */
+                                  0,                                   /* 
relkind, also N/A here */
+                                  -1,                                  /* 
Internal size, unlimited */
+                                  'c',                                 /* It's 
a complex type */
+                                  DEFAULT_TYPDELIM,    /* Use the default */
+                                  F_ARRAY_IN,                  /* Macro for 
array input procedure */
+                                  F_ARRAY_OUT,                 /* Macro for 
array output procedure */
+                                  F_ARRAY_RECV,                /* Macro for 
array receive (binary input) procedure */
+                                  F_ARRAY_SEND,                /* Macro for 
array send (binary output) procedure */
+                                  -1,                                  /* No 
input typmod */
+                                  -1,                                  /* No 
output typmod */
+                                  InvalidOid,                  /* Default 
ANALYZE procedure */
+                                  relationId,                  /* The OID just 
created */
+                                  InvalidOid,                  /* No base 
type--this isn't a DOMAIN */
+                                  NULL,                                /* No 
default type value */
+                                  NULL,                                /* 
Don't send binary */
+                                  false,                               /* 
Never passed by value */
+                                  'd',                                 /* Type 
alignment.  Should this be something else? */
+                                  'x',                                 /* 
Always TOASTable */
+                                  -1,                                  /* No 
typMod for regular composite types.  When we have domains over these, we should 
revisit. */
+                                  0,                                   /* 
Array diminsions of typbasetype */
+                                  false);                              /* Type 
NOT NULL */
+               pfree(relarrayname);    /* Seems like the right thing to do 
here. */
+       }
+ 
        return relationId;
  }
  
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to