Fix atttypmod alignment again, and re-enable ecpg.
authorBruce Momjian
Wed, 26 Aug 1998 16:43:54 +0000 (16:43 +0000)
committerBruce Momjian
Wed, 26 Aug 1998 16:43:54 +0000 (16:43 +0000)
src/backend/commands/defind.c
src/backend/parser/gram.c
src/include/catalog/pg_attribute.h
src/include/catalog/pg_attribute_check.sql [new file with mode: 0644]
src/interfaces/Makefile
src/interfaces/ecpg/preproc/preproc.y

index ee4678372e0832a0e21b79166db9b4119cbe17a6..7df18c0f69833b94c7a87997393c7f189846ff5f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.23 1998/08/26 05:22:36 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.24 1998/08/26 16:43:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -468,7 +468,7 @@ NormIndexAttrs(List *attList,   /* list of IndexElem's */
               Oid relId)
 {
    List       *rest;
-   HeapTuple   tuple;
+   HeapTuple   atttuple, tuple;
 
    /*
     * process attributeList
@@ -484,20 +484,34 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
        if (attribute->name == NULL)
            elog(ERROR, "missing attribute for define index");
 
-       tuple = SearchSysCacheTuple(ATTNAME,
+       atttuple = SearchSysCacheTupleCopy(ATTNAME,
                                    ObjectIdGetDatum(relId),
                                    PointerGetDatum(attribute->name),
                                    0, 0);
-       if (!HeapTupleIsValid(tuple))
+       if (!HeapTupleIsValid(atttuple))
        {
            elog(ERROR,
                 "DefineIndex: attribute \"%s\" not found",
                 attribute->name);
        }
 
-       attform = (AttributeTupleForm) GETSTRUCT(tuple);
+       attform = (AttributeTupleForm) GETSTRUCT(atttuple);
        *attNumP++ = attform->attnum;
 
+       /* we want the type so we can set the proper alignment, etc. */
+       if (attribute->typename == NULL)
+       {
+           tuple = SearchSysCacheTuple(TYPOID,
+                                     ObjectIdGetDatum(attform->atttypid),
+                                     0, 0, 0);
+           if (!HeapTupleIsValid(tuple))
+               elog(ERROR, "create index: type for attribute '%s' undefined",
+                    attribute->name);
+           /* we just set the type name because that is all we need */
+           attribute->typename = makeNode(TypeName);
+           attribute->typename->name = nameout(&((TypeTupleForm) GETSTRUCT(tuple))->typname);
+       }
+
        if (attribute->class == NULL)
        {
            /* no operator class specified, so find the default */
@@ -520,21 +534,7 @@ NormIndexAttrs(List *attList,  /* list of IndexElem's */
                 attribute->class);
        }
        *classOidP++ = tuple->t_oid;
-       /* we want the type so we can set the proper alignment, etc. */
-       if (attribute->typename == NULL)
-       {
-           Oid typoid = ((Form_pg_opclass) GETSTRUCT(tuple))->opcdeftype;
-           
-           tuple = SearchSysCacheTuple(TYPOID,
-                                     ObjectIdGetDatum(typoid),
-                                     0, 0, 0);
-           if (!HeapTupleIsValid(tuple))
-               elog(ERROR, "create index: type for class '%s' undefined",
-                    attribute->class);
-           /* we just set the name because that is all we need */
-           attribute->typename = makeNode(TypeName);
-           attribute->typename->name = nameout(&((TypeTupleForm) GETSTRUCT(tuple))->typname);
-       }
+       pfree(atttuple);
    }
 }
 
index af47e7be0e81cffcfdc4882b7e2d6d94bfe3861a..5206df9637672232a52c48e87cc69e0b44cabf70 100644 (file)
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.30 1998/08/26 05:22:43 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.31 1998/08/26 16:43:43 momjian Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
index d908c54dcc0b114a913eed5ba272c6402916a291..0e88c86904f290925eee14a335f5d0da1ddf64c6 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_attribute.h,v 1.37 1998/08/26 05:51:24 momjian Exp $
+ * $Id: pg_attribute.h,v 1.38 1998/08/26 16:43:48 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -339,7 +339,7 @@ DATA(insert OID = 0 ( 1249 attlen           21 0  2   5 0 -1 -1 t f s f f));
 DATA(insert OID = 0 ( 1249 attnum          21 0  2   6 0 -1 -1 t f s f f));
 DATA(insert OID = 0 ( 1249 attnelems       23 0  4   7 0 -1 -1 t f i f f));
 DATA(insert OID = 0 ( 1249 attcacheoff     23 0  4   8 0 -1 -1 t f i f f));
-DATA(insert OID = 0 ( 1249 atttypmod       21 0  4   9 0 -1 -1 t f s f f));
+DATA(insert OID = 0 ( 1249 atttypmod       23 0  4   9 0 -1 -1 t f i f f));
 DATA(insert OID = 0 ( 1249 attbyval            16 0  1  10 0 -1 -1 t f c f f));
 DATA(insert OID = 0 ( 1249 attisset            16 0  1  11 0 -1 -1 t f c f f));
 DATA(insert OID = 0 ( 1249 attalign            18 0  1  12 0 -1 -1 t f c f f));
diff --git a/src/include/catalog/pg_attribute_check.sql b/src/include/catalog/pg_attribute_check.sql
new file mode 100644 (file)
index 0000000..20264fb
--- /dev/null
@@ -0,0 +1,17 @@
+-- This makes sure the pg_attribute columns match the type's columns
+-- bjm 1998/08/26
+
+-- check lengths
+SELECT pg_attribute.oid, relname, attname
+FROM   pg_class, pg_attribute, pg_type
+WHERE  pg_class.oid = attrelid AND
+   atttypid = pg_type.oid AND
+   attlen != typlen;
+
+-- check alignment
+SELECT pg_attribute.oid, relname, attname
+FROM   pg_class, pg_attribute, pg_type
+WHERE  pg_class.oid = attrelid AND
+   atttypid = pg_type.oid AND
+   attalign != typalign;
+
index 6ff3ac386e87b577d1660af1cb200cdac35ab9b8..37e286c2d25c8d716afa9b6bcb6c9f6b5c4ba3a4 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.14 1998/08/26 05:22:58 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.15 1998/08/26 16:43:51 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,7 +23,7 @@ endif
 
 .DEFAULT all install clean dep depend distclean: $(perl-makefile-dep)
    $(MAKE) -C libpq $@
-#  $(MAKE) -C ecpg $@
+   $(MAKE) -C ecpg $@
 ifeq ($(HAVE_Cplusplus), true)
    $(MAKE) -C libpq++ $@
 else
index cc8528e4355854dd939c71bbb7c5db883432b74b..fec7232375ec5088723386a88fcab308219bc32b 100644 (file)
@@ -641,7 +641,7 @@ output_statement(char * stmt, int mode)
 %type     join_using where_clause relation_expr row_op sub_type
 %type     opt_column_list insert_rest InsertStmt OptimizableStmt
 %type      columnList DeleteStmt LockStmt UpdateStmt CursorStmt
-%type      NotifyStmt columnElem copy_dirn SubUnion c_expr
+%type      NotifyStmt columnElem copy_dirn SubUnion c_expr UnlistenStmt
 %type      copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
 %type      opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name
 %type      ClosePortalStmt DestroyStmt VacuumStmt opt_verbose