Index: src/backend/catalog/heap.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/catalog/heap.c,v retrieving revision 1.317 diff -c -r1.317 heap.c *** src/backend/catalog/heap.c 14 Feb 2007 01:58:56 -0000 1.317 --- src/backend/catalog/heap.c 27 Mar 2007 19:33:52 -0000 *************** *** 45,50 **** --- 45,51 ---- #include "catalog/pg_statistic.h" #include "catalog/pg_type.h" #include "commands/tablecmds.h" + #include "commands/typecmds.h" #include "miscadmin.h" #include "optimizer/clauses.h" #include "optimizer/var.h" *************** *** 763,768 **** --- 764,770 ---- Relation pg_class_desc; Relation new_rel_desc; Oid new_type_oid; + char *relarrayname; pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock); *************** *** 815,820 **** --- 817,857 ---- relnamespace, relid, relkind); + /* + * Add in the corresponding array types if appropriate. + */ + if ( + relnamespace != 11 && /* pg_catalog's namespace */ + (relkind == 'r' || relkind == 'v' || relkind == 'c') + ) + { + relarrayname = makeArrayTypeName(relname); + TypeCreate(relarrayname, /* Array type name */ + relnamespace, /* Same namespace as parent */ + new_type_oid, /* relation's type oid */ + 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 */ + relid, /* 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. */ + } /* * now create an entry in pg_class for the relation. 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 19:33:54 -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' || relkind == 'c') ! ) ! { ! StrNCpy(relname, stmt->relation->relname, NAMEDATALEN-2); ! } ! else ! { ! StrNCpy(relname, stmt->relation->relname, NAMEDATALEN); ! } /* * Check consistency of arguments