On Tue, Mar 27, 2007 at 11:08:44AM -0700, David Fetter wrote:
> 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?
Pardon the self-follow-up.
Per further discussion with Andrew of Supernews and Merlin Moncure,
I've added a check for compound types and moved the creation of the
array type from DefineRelation in backend/commands/tablecmds.c to
heap_create_with_catalog in backend/catalog/heap.c.
It now initdb's successfully, but fails on a lot of regression tests.
Please find attached the new patch vs. CVS TIP and the regression test
output.
Am I on the right track here?
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
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
parallel group (14 tests): boolean char varchar text int2 int8 name int4 oid
float4 float8 bit uuid numeric
boolean ... ok
char ... FAILED
name ... ok
varchar ... FAILED
text ... ok
int2 ... ok
int4 ... ok
int8 ... ok
oid ... ok
float4 ... ok
float8 ... ok
bit ... FAILED
numeric ... ok
uuid ... ok
test strings ... FAILED
test numerology ... ok
parallel group (20 tests): point lseg box path circle date timetz polygon time
interval abstime inet comments timestamptz reltime timestamp oidjoins tinterval
type_sanity opr_sanity
point ... ok
lseg ... ok
box ... ok
path ... ok
polygon ... ok
circle ... ok
date ... ok
time ... ok
timetz ... ok
timestamp ... ok
timestamptz ... ok
interval ... ok
abstime ... ok
reltime ... ok
tinterval ... ok
inet ... ok
comments ... ok
oidjoins ... FAILED
type_sanity ... ok
opr_sanity ... ok
test geometry ... ok
test horology ... ok
test insert ... ok
test create_function_1 ... ok
test create_type ... ok
test create_table ... ok
test create_function_2 ... ok
parallel group (2 tests): copyselect copy
copy ... ok
copyselect ... ok
parallel group (8 tests): constraints triggers create_misc create_aggregate
inherit vacuum drop_if_exists create_operator
constraints ... FAILED
triggers ... FAILED
create_misc ... ok
create_aggregate ... ok
create_operator ... ok
inherit ... FAILED
vacuum ... ok
drop_if_exists ... ok
parallel group (2 tests): create_view create_index
create_index ... FAILED
create_view ... ok
test sanity_check ... FAILED
test errors ... ok
test select ... FAILED
parallel group (20 tests): select_distinct_on union btree_index
select_distinct select_into select_implicit select_having subselect case join
transactions random aggregates portals hash_index arrays namespace update
delete prepared_xacts
select_into ... FAILED
select_distinct ... FAILED
select_distinct_on ... FAILED
select_implicit ... ok
select_having ... ok
subselect ... ok
union ... FAILED
case ... ok
join ... ok
aggregates ... ok
transactions ... ok
random ... ok
portals ... ok
arrays ... ok
btree_index ... ok
hash_index ... ok
update ... ok
namespace ... ok
prepared_xacts ... ok
delete ... ok
test privileges ... FAILED
test misc ... FAILED
parallel group (8 tests): select_views portals_p2 rules foreign_key cluster
dependency combocid guc
select_views ... ok
portals_p2 ... ok
rules ... FAILED
foreign_key ... FAILED
cluster ... FAILED
dependency ... FAILED
guc ... ok
combocid ... ok
parallel group (18 tests): plancache limit copy2 temp rangefuncs prepare
without_oid conversion plpgsql polymorphism domain rowtypes xml alter_table
truncate sequence returning largeobject
plancache ... FAILED
limit ... ok
plpgsql ... FAILED
copy2 ... ok
temp ... FAILED
domain ... ok
rangefuncs ... FAILED
prepare ... ok
without_oid ... ok
conversion ... ok
truncate ... ok
alter_table ... FAILED
sequence ... ok
polymorphism ... ok
rowtypes ... ok
returning ... ok
largeobject ... ok
xml ... ok
test stats ... ok
test tablespace ... ok
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq