@@ -694,7 +694,7 @@ RemoveTypeById(Oid typeOid)
694
694
* Registers a new domain.
695
695
*/
696
696
ObjectAddress
697
- DefineDomain (CreateDomainStmt * stmt )
697
+ DefineDomain (ParseState * pstate , CreateDomainStmt * stmt )
698
698
{
699
699
char * domainName ;
700
700
char * domainArrayName ;
@@ -761,7 +761,7 @@ DefineDomain(CreateDomainStmt *stmt)
761
761
/*
762
762
* Look up the base type.
763
763
*/
764
- typeTup = typenameType (NULL , stmt -> typeName , & basetypeMod );
764
+ typeTup = typenameType (pstate , stmt -> typeName , & basetypeMod );
765
765
baseType = (Form_pg_type ) GETSTRUCT (typeTup );
766
766
basetypeoid = baseType -> oid ;
767
767
@@ -783,7 +783,8 @@ DefineDomain(CreateDomainStmt *stmt)
783
783
ereport (ERROR ,
784
784
(errcode (ERRCODE_DATATYPE_MISMATCH ),
785
785
errmsg ("\"%s\" is not a valid base type for a domain" ,
786
- TypeNameToString (stmt -> typeName ))));
786
+ TypeNameToString (stmt -> typeName )),
787
+ parser_errposition (pstate , stmt -> typeName -> location )));
787
788
788
789
aclresult = object_aclcheck (TypeRelationId , basetypeoid , GetUserId (), ACL_USAGE );
789
790
if (aclresult != ACLCHECK_OK )
@@ -809,7 +810,8 @@ DefineDomain(CreateDomainStmt *stmt)
809
810
ereport (ERROR ,
810
811
(errcode (ERRCODE_DATATYPE_MISMATCH ),
811
812
errmsg ("collations are not supported by type %s" ,
812
- format_type_be (basetypeoid ))));
813
+ format_type_be (basetypeoid )),
814
+ parser_errposition (pstate , stmt -> typeName -> location )));
813
815
814
816
/* passed by value */
815
817
byValue = baseType -> typbyval ;
@@ -879,18 +881,15 @@ DefineDomain(CreateDomainStmt *stmt)
879
881
*/
880
882
if (saw_default )
881
883
ereport (ERROR ,
882
- (errcode (ERRCODE_SYNTAX_ERROR ),
883
- errmsg ("multiple default expressions" )));
884
+ errcode (ERRCODE_SYNTAX_ERROR ),
885
+ errmsg ("multiple default expressions" ),
886
+ parser_errposition (pstate , constr -> location ));
884
887
saw_default = true;
885
888
886
889
if (constr -> raw_expr )
887
890
{
888
- ParseState * pstate ;
889
891
Node * defaultExpr ;
890
892
891
- /* Create a dummy ParseState for transformExpr */
892
- pstate = make_parsestate (NULL );
893
-
894
893
/*
895
894
* Cook the constr->raw_expr into an expression. Note:
896
895
* name is strictly for error message
@@ -942,21 +941,24 @@ DefineDomain(CreateDomainStmt *stmt)
942
941
case CONSTR_NOTNULL :
943
942
if (nullDefined && !typNotNull )
944
943
ereport (ERROR ,
945
- (errcode (ERRCODE_SYNTAX_ERROR ),
946
- errmsg ("conflicting NULL/NOT NULL constraints" )));
944
+ errcode (ERRCODE_SYNTAX_ERROR ),
945
+ errmsg ("conflicting NULL/NOT NULL constraints" ),
946
+ parser_errposition (pstate , constr -> location ));
947
947
if (constr -> is_no_inherit )
948
948
ereport (ERROR ,
949
949
errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
950
- errmsg ("not-null constraints for domains cannot be marked NO INHERIT" ));
950
+ errmsg ("not-null constraints for domains cannot be marked NO INHERIT" ),
951
+ parser_errposition (pstate , constr -> location ));
951
952
typNotNull = true;
952
953
nullDefined = true;
953
954
break ;
954
955
955
956
case CONSTR_NULL :
956
957
if (nullDefined && typNotNull )
957
958
ereport (ERROR ,
958
- (errcode (ERRCODE_SYNTAX_ERROR ),
959
- errmsg ("conflicting NULL/NOT NULL constraints" )));
959
+ errcode (ERRCODE_SYNTAX_ERROR ),
960
+ errmsg ("conflicting NULL/NOT NULL constraints" ),
961
+ parser_errposition (pstate , constr -> location ));
960
962
typNotNull = false;
961
963
nullDefined = true;
962
964
break ;
@@ -971,35 +973,41 @@ DefineDomain(CreateDomainStmt *stmt)
971
973
*/
972
974
if (constr -> is_no_inherit )
973
975
ereport (ERROR ,
974
- (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
975
- errmsg ("check constraints for domains cannot be marked NO INHERIT" )));
976
+ errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
977
+ errmsg ("check constraints for domains cannot be marked NO INHERIT" ),
978
+ parser_errposition (pstate , constr -> location ));
979
+
976
980
break ;
977
981
978
982
/*
979
983
* All else are error cases
980
984
*/
981
985
case CONSTR_UNIQUE :
982
986
ereport (ERROR ,
983
- (errcode (ERRCODE_SYNTAX_ERROR ),
984
- errmsg ("unique constraints not possible for domains" )));
987
+ errcode (ERRCODE_SYNTAX_ERROR ),
988
+ errmsg ("unique constraints not possible for domains" ),
989
+ parser_errposition (pstate , constr -> location ));
985
990
break ;
986
991
987
992
case CONSTR_PRIMARY :
988
993
ereport (ERROR ,
989
994
(errcode (ERRCODE_SYNTAX_ERROR ),
990
- errmsg ("primary key constraints not possible for domains" )));
995
+ errmsg ("primary key constraints not possible for domains" ),
996
+ parser_errposition (pstate , constr -> location )));
991
997
break ;
992
998
993
999
case CONSTR_EXCLUSION :
994
1000
ereport (ERROR ,
995
1001
(errcode (ERRCODE_SYNTAX_ERROR ),
996
- errmsg ("exclusion constraints not possible for domains" )));
1002
+ errmsg ("exclusion constraints not possible for domains" ),
1003
+ parser_errposition (pstate , constr -> location )));
997
1004
break ;
998
1005
999
1006
case CONSTR_FOREIGN :
1000
1007
ereport (ERROR ,
1001
1008
(errcode (ERRCODE_SYNTAX_ERROR ),
1002
- errmsg ("foreign key constraints not possible for domains" )));
1009
+ errmsg ("foreign key constraints not possible for domains" ),
1010
+ parser_errposition (pstate , constr -> location )));
1003
1011
break ;
1004
1012
1005
1013
case CONSTR_ATTR_DEFERRABLE :
@@ -1008,14 +1016,16 @@ DefineDomain(CreateDomainStmt *stmt)
1008
1016
case CONSTR_ATTR_IMMEDIATE :
1009
1017
ereport (ERROR ,
1010
1018
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1011
- errmsg ("specifying constraint deferrability not supported for domains" )));
1019
+ errmsg ("specifying constraint deferrability not supported for domains" ),
1020
+ parser_errposition (pstate , constr -> location )));
1012
1021
break ;
1013
1022
1014
1023
case CONSTR_GENERATED :
1015
1024
case CONSTR_IDENTITY :
1016
1025
ereport (ERROR ,
1017
1026
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1018
- errmsg ("specifying GENERATED not supported for domains" )));
1027
+ errmsg ("specifying GENERATED not supported for domains" ),
1028
+ parser_errposition (pstate , constr -> location )));
1019
1029
break ;
1020
1030
1021
1031
/* no default, to let compiler warn about missing case */
0 commit comments