@@ -478,7 +478,7 @@ static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid,
478478static void RangeVarCallbackForAlterRelation (const RangeVar * rv ,Oid relid ,
479479Oid oldrelid ,void * arg );
480480static PartitionSpec * transformPartitionSpec (Relation rel ,PartitionSpec * partspec ,char * strategy );
481- static void ComputePartitionAttrs (Relation rel ,List * partParams ,AttrNumber * partattrs ,
481+ static void ComputePartitionAttrs (ParseState * pstate , Relation rel ,List * partParams ,AttrNumber * partattrs ,
482482List * * partexprs ,Oid * partopclass ,Oid * partcollation ,char strategy );
483483static void CreateInheritance (Relation child_rel ,Relation parent_rel );
484484static void RemoveInheritance (Relation child_rel ,Relation parent_rel );
@@ -875,13 +875,17 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
875875 */
876876if (stmt -> partspec )
877877{
878+ ParseState * pstate ;
878879char strategy ;
879880int partnatts ;
880881AttrNumber partattrs [PARTITION_MAX_KEYS ];
881882Oid partopclass [PARTITION_MAX_KEYS ];
882883Oid partcollation [PARTITION_MAX_KEYS ];
883884List * partexprs = NIL ;
884885
886+ pstate = make_parsestate (NULL );
887+ pstate -> p_sourcetext = queryString ;
888+
885889partnatts = list_length (stmt -> partspec -> partParams );
886890
887891/* Protect fixed-size arrays here and in executor */
@@ -900,7 +904,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
900904stmt -> partspec = transformPartitionSpec (rel ,stmt -> partspec ,
901905& strategy );
902906
903- ComputePartitionAttrs (rel ,stmt -> partspec -> partParams ,
907+ ComputePartitionAttrs (pstate , rel ,stmt -> partspec -> partParams ,
904908partattrs ,& partexprs ,partopclass ,
905909partcollation ,strategy );
906910
@@ -13695,7 +13699,7 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
1369513699 * Expressions in the PartitionElems must be parse-analyzed already.
1369613700 */
1369713701static void
13698- ComputePartitionAttrs (Relation rel ,List * partParams ,AttrNumber * partattrs ,
13702+ ComputePartitionAttrs (ParseState * pstate , Relation rel ,List * partParams ,AttrNumber * partattrs ,
1369913703List * * partexprs ,Oid * partopclass ,Oid * partcollation ,
1370013704char strategy )
1370113705{
@@ -13722,14 +13726,16 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs,
1372213726ereport (ERROR ,
1372313727(errcode (ERRCODE_UNDEFINED_COLUMN ),
1372413728errmsg ("column \"%s\" named in partition key does not exist" ,
13725- pelem -> name )));
13729+ pelem -> name ),
13730+ parser_errposition (pstate ,pelem -> location )));
1372613731attform = (Form_pg_attribute )GETSTRUCT (atttuple );
1372713732
1372813733if (attform -> attnum <=0 )
1372913734ereport (ERROR ,
1373013735(errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1373113736errmsg ("cannot use system column \"%s\" in partition key" ,
13732- pelem -> name )));
13737+ pelem -> name ),
13738+ parser_errposition (pstate ,pelem -> location )));
1373313739
1373413740partattrs [attn ]= attform -> attnum ;
1373513741atttype = attform -> atttypid ;