OSDN Git Service

Fix outdated comment
[pg-rex/syncrep.git] / src / backend / parser / parse_utilcmd.c
index efb8fdd..d40a963 100644 (file)
@@ -307,7 +307,14 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
        {
                char       *typname = strVal(linitial(column->typeName->names));
 
-               if (strcmp(typname, "serial") == 0 ||
+               if (strcmp(typname, "smallserial") == 0 ||
+                       strcmp(typname, "serial2") == 0)
+               {
+                       is_serial = true;
+                       column->typeName->names = NIL;
+                       column->typeName->typeOid = INT2OID;
+               }
+               else if (strcmp(typname, "serial") == 0 ||
                        strcmp(typname, "serial4") == 0)
                {
                        is_serial = true;
@@ -845,7 +852,6 @@ static void
 transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
 {
        HeapTuple       tuple;
-       Form_pg_type typ;
        TupleDesc       tupdesc;
        int                     i;
        Oid                     ofTypeId;
@@ -854,7 +860,6 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
 
        tuple = typenameType(NULL, ofTypename, NULL);
        check_of_type(tuple);
-       typ = (Form_pg_type) GETSTRUCT(tuple);
        ofTypeId = HeapTupleGetOid(tuple);
        ofTypename->typeOid = ofTypeId;         /* cached for later */
 
@@ -1483,21 +1488,21 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
                        ereport(ERROR,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                         errmsg("\"%s\" is not a unique index", index_name),
-                                        errdetail("Cannot create a PRIMARY KEY or UNIQUE constraint using such an index."),
+                                        errdetail("Cannot create a primary key or unique constraint using such an index."),
                                         parser_errposition(cxt->pstate, constraint->location)));
 
                if (RelationGetIndexExpressions(index_rel) != NIL)
                        ereport(ERROR,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                         errmsg("index \"%s\" contains expressions", index_name),
-                                        errdetail("Cannot create a PRIMARY KEY or UNIQUE constraint using such an index."),
+                                        errdetail("Cannot create a primary key or unique constraint using such an index."),
                                         parser_errposition(cxt->pstate, constraint->location)));
 
                if (RelationGetIndexPredicate(index_rel) != NIL)
                        ereport(ERROR,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                         errmsg("\"%s\" is a partial index", index_name),
-                                        errdetail("Cannot create a PRIMARY KEY or UNIQUE constraint using such an index."),
+                                        errdetail("Cannot create a primary key or unique constraint using such an index."),
                                         parser_errposition(cxt->pstate, constraint->location)));
 
                /*
@@ -1567,7 +1572,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
                                ereport(ERROR,
                                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                                 errmsg("index \"%s\" does not have default sorting behavior", index_name),
-                                                errdetail("Cannot create a PRIMARY KEY or UNIQUE constraint using such an index."),
+                                                errdetail("Cannot create a primary key or unique constraint using such an index."),
                                         parser_errposition(cxt->pstate, constraint->location)));
 
                        constraint->keys = lappend(constraint->keys, makeString(attname));
@@ -1753,7 +1758,8 @@ transformFKConstraints(CreateStmtContext *cxt,
 
        /*
         * If CREATE TABLE or adding a column with NULL default, we can safely
-        * skip validation of the constraint.
+        * skip validation of FK constraints, and nonetheless mark them valid.
+        * (This will override any user-supplied NOT VALID flag.)
         */
        if (skipValidation)
        {
@@ -2412,8 +2418,8 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString)
  * and detect inconsistent/misplaced constraint attributes.
  *
  * NOTE: currently, attributes are only supported for FOREIGN KEY, UNIQUE,
- * and PRIMARY KEY constraints, but someday they ought to be supported
- * for other constraint types.
+ * EXCLUSION, and PRIMARY KEY constraints, but someday they ought to be
+ * supported for other constraint types.
  */
 static void
 transformConstraintAttrs(CreateStmtContext *cxt, List *constraintList)