I wrote: > I'd like to take the TODO item that reads, "Add support for arrays of > complex types," but before I start patching, I'd like to see whether > what I'm about to do makes any sense:
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? Cheers, David. > > 1. In src/backend/commands/tablecmds.c, change DefineRelation as > follows: > > * After the first call to heap_create_with_catalog, construct and > do another call to for the array type. > > * Add an appropriate pg_depend entry. > > 2. Change RemoveRelation to reflect the above. > > 3. Change TypeRename appropriately, whatever that turns out to be. > > Does the above make sense? Have I missed anything critical? > > Cheers, > D > -- > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster -- 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 26 Mar 2007 00:30:08 -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,307 ---- 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 (relkind == 'r' || relkind == 'v' && !IsBootstrapProcessingMode()) ! { ! StrNCpy(relname, stmt->relation->relname, NAMEDATALEN-2); ! } ! else ! { ! StrNCpy(relname, stmt->relation->relname, NAMEDATALEN); ! } /* * Check consistency of arguments *************** *** 496,501 **** --- 505,543 ---- */ relation_close(rel, NoLock); + /* + * Add the array type if appropriate. + */ + if (relkind == 'r' || relkind == 'v' && !IsBootstrapProcessingMode()) + { + relarrayname = makeArrayTypeName(relname); + TypeCreate(relarrayname, /* Array type name */ + namespaceId, /* Same namespace as parent */ + InvalidOid, /* 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; } Index: src/include/catalog/catversion.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/catalog/catversion.h,v retrieving revision 1.394 diff -c -r1.394 catversion.h *** src/include/catalog/catversion.h 25 Mar 2007 11:56:04 -0000 1.394 --- src/include/catalog/catversion.h 26 Mar 2007 00:30:10 -0000 *************** *** 48,58 **** * We could use anything we wanted for version numbers, but I recommend * following the "YYYYMMDDN" style often used for DNS zone serial numbers. * YYYYMMDD are the date of the change, and N is the number of the change ! * on that day. (Hopefully we'll never commit ten independent sets of ! * catalog changes on the same day...) */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 200703251 #endif --- 48,58 ---- * We could use anything we wanted for version numbers, but I recommend * following the "YYYYMMDDN" style often used for DNS zone serial numbers. * YYYYMMDD are the date of the change, and N is the number of the change ! * on that day. (Let's hope we'll never commit ten independent sets ! * of catalog changes on the same day...) */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 200703252 #endif
Running in noclean mode. Mistakes will not be cleaned up. The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale C. creating directory /var/lib/pgsql/pgsql/src/test/regress/./tmp_check/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers/max_fsm_pages ... 32MB/204800 creating configuration files ... ok 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 initdb: data directory "/var/lib/pgsql/pgsql/src/test/regress/./tmp_check/data" not removed at user's request
---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate