diff options
Diffstat (limited to 'src/backend/parser')
| -rw-r--r-- | src/backend/parser/gram.y | 3 | ||||
| -rw-r--r-- | src/backend/parser/parse_utilcmd.c | 14 | 
2 files changed, 15 insertions, 2 deletions
| diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 122213a134f..50ed8716ca8 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@   *   *   * IDENTIFICATION - *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.713 2010/06/13 17:43:12 rhaas Exp $ + *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.713.2.1 2010/08/18 18:35:30 tgl Exp $   *   * HISTORY   *	  AUTHOR			DATE			MAJOR EVENT @@ -2793,6 +2793,7 @@ CreateSeqStmt:  					$4->istemp = $2;  					n->sequence = $4;  					n->options = $5; +					n->ownerId = InvalidOid;  					$$ = (Node *)n;  				}  		; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 1657096c6d8..d1e1dac3a1e 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -19,7 +19,7 @@   * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group   * Portions Copyright (c) 1994, Regents of the University of California   * - *	$PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.40 2010/02/26 02:00:53 momjian Exp $ + *	$PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.40.4.1 2010/08/18 18:35:30 tgl Exp $   *   *-------------------------------------------------------------------------   */ @@ -360,6 +360,18 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,  		seqstmt->sequence = makeRangeVar(snamespace, sname, -1);  		seqstmt->options = NIL; +		/* +		 * If this is ALTER ADD COLUMN, make sure the sequence will be owned +		 * by the table's owner.  The current user might be someone else +		 * (perhaps a superuser, or someone who's only a member of the owning +		 * role), but the SEQUENCE OWNED BY mechanisms will bleat unless +		 * table and sequence have exactly the same owning role. +		 */ +		if (cxt->rel) +			seqstmt->ownerId = cxt->rel->rd_rel->relowner; +		else +			seqstmt->ownerId = InvalidOid; +  		cxt->blist = lappend(cxt->blist, seqstmt);  		/* | 
