*             back to source text
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.155 2003/09/29 18:55:56 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.156 2003/10/02 22:24:54 tgl Exp $
  *
  *   This software is copyrighted by Jan Wieck - Hamburg.
  *
    Form_pg_opclass opcrec;
    char       *opcname;
    char       *nspname;
+   bool        isvisible;
 
    /* Domains use their base type's default opclass */
    if (OidIsValid(actual_datatype))
            OidIsValid(get_element_type(actual_datatype)))
            actual_datatype = opcrec->opcintype;
    }
+
+   /* Must force use of opclass name if not in search path */
+   isvisible = OpclassIsVisible(opclass);
    
-   if (actual_datatype != opcrec->opcintype || !opcrec->opcdefault)
+   if (actual_datatype != opcrec->opcintype || !opcrec->opcdefault ||
+       !isvisible)
    {
        /* Okay, we need the opclass name.  Do we need to qualify it? */
        opcname = NameStr(opcrec->opcname);
-       if (OpclassIsVisible(opclass))
+       if (isvisible)
            appendStringInfo(buf, " %s", quote_identifier(opcname));
        else
        {