55 *
66 * Copyright (c) 1994, Regents of the University of California
77 *
8- * $Id: analyze.c,v 1.103 1999/05/1307:28:34 tgl Exp $
8+ * $Id: analyze.c,v 1.104 1999/05/1315:01:32 thomas Exp $
99 *
1010 *-------------------------------------------------------------------------
1111 */
@@ -546,39 +546,22 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
546546constraint -> contype = CONSTR_DEFAULT ;
547547constraint -> name = sname ;
548548cstring = palloc (9 + strlen (constraint -> name )+ 2 + 1 );
549- strcpy (cstring ,"nextval('" );
549+ strcpy (cstring ,"nextval('\" " );
550550strcat (cstring ,constraint -> name );
551- strcat (cstring ,"')" );
551+ strcat (cstring ,"\" ')" );
552552constraint -> def = cstring ;
553553constraint -> keys = NULL ;
554554
555- #if 0
556- /* The parser only allows PRIMARY KEY as a constraint for the SERIAL type.
557- * So, if there is a constraint of any kind, assume it is that.
558- * If PRIMARY KEY is specified, then don't need to gin up a UNIQUE constraint
559- * since that will be covered already.
560- * - thomas 1998-09-15
561- */
562- if (column -> constraints != NIL )
563- {
564- column -> constraints = lappend (column -> constraints ,constraint );
565- }
566- else
567- {
568- #endif
569- column -> constraints = lappend (column -> constraints ,constraint );
555+ column -> constraints = lappend (column -> constraints ,constraint );
570556
571- constraint = makeNode (Constraint );
572- constraint -> contype = CONSTR_UNIQUE ;
573- constraint -> name = makeTableName (stmt -> relname ,column -> colname ,"key" ,NULL );
574- if (constraint -> name == NULL )
575- elog (ERROR ,"CREATE TABLE/SERIAL implicit index name must be less than %d characters"
576- "\n\tSum of lengths of '%s' and '%s' must be less than %d" ,
577- NAMEDATALEN ,stmt -> relname ,column -> colname , (NAMEDATALEN - 5 ));
578- column -> constraints = lappend (column -> constraints ,constraint );
579- #if 0
580- }
581- #endif
557+ constraint = makeNode (Constraint );
558+ constraint -> contype = CONSTR_UNIQUE ;
559+ constraint -> name = makeTableName (stmt -> relname ,column -> colname ,"key" ,NULL );
560+ if (constraint -> name == NULL )
561+ elog (ERROR ,"CREATE TABLE/SERIAL implicit index name must be less than %d characters"
562+ "\n\tSum of lengths of '%s' and '%s' must be less than %d" ,
563+ NAMEDATALEN ,stmt -> relname ,column -> colname , (NAMEDATALEN - 5 ));
564+ column -> constraints = lappend (column -> constraints ,constraint );
582565
583566sequence = makeNode (CreateSeqStmt );
584567sequence -> seqname = pstrdup (sname );
@@ -604,21 +587,21 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
604587 */
605588if (column -> is_not_null )
606589elog (ERROR ,"CREATE TABLE/(NOT) NULL conflicting declaration"
607- " for %s.%s" ,stmt -> relname ,column -> colname );
590+ " for' %s.%s' " ,stmt -> relname ,column -> colname );
608591column -> is_not_null = FALSE;
609592break ;
610593
611594case CONSTR_NOTNULL :
612595if (column -> is_not_null )
613596elog (ERROR ,"CREATE TABLE/NOT NULL already specified"
614- " for %s.%s" ,stmt -> relname ,column -> colname );
597+ " for' %s.%s' " ,stmt -> relname ,column -> colname );
615598column -> is_not_null = TRUE;
616599break ;
617600
618601case CONSTR_DEFAULT :
619602if (column -> defval != NULL )
620603elog (ERROR ,"CREATE TABLE/DEFAULT multiple values specified"
621- " for %s.%s" ,stmt -> relname ,column -> colname );
604+ " for' %s.%s' " ,stmt -> relname ,column -> colname );
622605column -> defval = constraint -> def ;
623606break ;
624607
@@ -680,10 +663,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
680663break ;
681664
682665case CONSTR_UNIQUE :
683- #ifdef NOT_USED
684- if (constraint -> name == NULL )
685- constraint -> name = makeTableName (stmt -> relname ,"key" ,NULL );
686- #endif
687666dlist = lappend (dlist ,constraint );
688667break ;
689668
@@ -735,7 +714,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
735714{
736715if (pkey != NULL )
737716elog (ERROR ,"CREATE TABLE/PRIMARY KEY multiple primary keys"
738- " for table%s are notlegal " ,stmt -> relname );
717+ " for table'%s' are notallowed " ,stmt -> relname );
739718pkey = (IndexStmt * )index ;
740719}
741720
@@ -796,14 +775,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
796775}
797776
798777if (index -> idxname == NULL )
799- elog (ERROR ,"CREATE TABLE unable to construct implicit index for table%s "
778+ elog (ERROR ,"CREATE TABLE unable to construct implicit index for table'%s' "
800779"; name too long" ,stmt -> relname );
801- #if 0
802- else
803- elog (NOTICE ,"CREATE TABLE/%s will create implicit index '%s' for table '%s'" ,
804- ((constraint -> contype == CONSTR_PRIMARY ) ?"PRIMARY KEY" :"UNIQUE" ),
805- index -> idxname ,stmt -> relname );
806- #endif
807780
808781ilist = lappend (ilist ,index );
809782dlist = lnext (dlist );
@@ -855,7 +828,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
855828extras_after = ilist ;
856829
857830return q ;
858- }
831+ }/* transformCreateStmt() */
859832
860833/*
861834 * transformIndexStmt -