* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: analyze.c,v 1.140 2000/03/14 23:06:30 thomas Exp $
+ * $Id: analyze.c,v 1.141 2000/03/24 23:34:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
foreach(ilist, indices)
{
IndexStmt *index = lfirst(ilist);
- if (strcasecmp(iname, index->idxname) == 0)
+ if (strcmp(iname, index->idxname) == 0)
break;
}
/* ran through entire list? then no name conflict found so done */
constraint->name = sname;
constraint->raw_expr = (Node *) funccallnode;
constraint->cooked_expr = NULL;
- constraint->keys = NULL;
+ constraint->keys = NIL;
column->constraints = lappend(column->constraints,
constraint);
if (constraint->name == NULL)
constraint->name = makeObjectName(stmt->relname, NULL, "pkey");
if (constraint->keys == NIL)
- constraint->keys = lappend(constraint->keys, column);
+ {
+ key = makeNode(Ident);
+ key->name = pstrdup(column->colname);
+ constraint->keys = lcons(key, NIL);
+ }
dlist = lappend(dlist, constraint);
break;
if (constraint->name == NULL)
constraint->name = makeObjectName(stmt->relname, column->colname, "key");
if (constraint->keys == NIL)
- constraint->keys = lappend(constraint->keys, column);
+ {
+ key = makeNode(Ident);
+ key->name = pstrdup(column->colname);
+ constraint->keys = lcons(key, NIL);
+ }
dlist = lappend(dlist, constraint);
break;
index->withClause = NIL;
index->whereClause = NULL;
- keys = constraint->keys;
- while (keys != NIL)
+ foreach(keys, constraint->keys)
{
- key = lfirst(keys);
- columns = stmt->tableElts;
+ key = (Ident *) lfirst(keys);
+ Assert(IsA(key, Ident));
column = NULL;
- while (columns != NIL)
+ foreach(columns, stmt->tableElts)
{
column = lfirst(columns);
- if (strcasecmp(column->colname, key->name) == 0)
+ Assert(IsA(column, ColumnDef));
+ if (strcmp(column->colname, key->name) == 0)
break;
- else
- column = NULL;
- columns = lnext(columns);
}
- if (column == NULL)
- elog(ERROR, "CREATE TABLE column '%s' in key does not exist", key->name);
+ if (columns == NIL) /* fell off end of list? */
+ elog(ERROR, "CREATE TABLE: column '%s' named in key does not exist",
+ key->name);
if (constraint->contype == CONSTR_PRIMARY)
column->is_not_null = TRUE;
if (index->idxname == NULL)
index->idxname = CreateIndexName(stmt->relname, iparam->name, "key", ilist);
-
- keys = lnext(keys);
}
if (index->idxname == NULL) /* should not happen */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.162 2000/03/21 06:00:40 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.163 2000/03/24 23:34:19 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
character: CHARACTER opt_varying opt_charset
{
char *type, *c;
- if (($3 == NULL) || (strcasecmp($3, "sql_text") == 0)) {
+ if (($3 == NULL) || (strcmp($3, "sql_text") == 0)) {
if ($2) type = xlateSqlType("varchar");
else type = xlateSqlType("bpchar");
} else {
static char *
xlateSqlFunc(char *name)
{
- if (!strcasecmp(name,"character_length"))
+ if (!strcmp(name,"character_length"))
return "char_length";
- else if (!strcasecmp(name,"datetime"))
+ else if (!strcmp(name,"datetime"))
return "timestamp";
- else if (!strcasecmp(name,"timespan"))
+ else if (!strcmp(name,"timespan"))
return "interval";
else
return name;
static char *
xlateSqlType(char *name)
{
- if (!strcasecmp(name,"int")
- || !strcasecmp(name,"integer"))
+ if (!strcmp(name,"int")
+ || !strcmp(name,"integer"))
return "int4";
- else if (!strcasecmp(name, "smallint"))
+ else if (!strcmp(name, "smallint"))
return "int2";
- else if (!strcasecmp(name, "real")
- || !strcasecmp(name, "float"))
+ else if (!strcmp(name, "real")
+ || !strcmp(name, "float"))
return "float8";
- else if (!strcasecmp(name, "decimal"))
+ else if (!strcmp(name, "decimal"))
return "numeric";
- else if (!strcasecmp(name, "datetime"))
+ else if (!strcmp(name, "datetime"))
return "timestamp";
- else if (!strcasecmp(name, "timespan"))
+ else if (!strcmp(name, "timespan"))
return "interval";
- else if (!strcasecmp(name, "boolean"))
+ else if (!strcmp(name, "boolean"))
return "bool";
else
return name;