99 *
1010 *
1111 * IDENTIFICATION
12- * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.122 2007/11/15 21:14:34 momjian Exp $
12+ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.123 2007/12/28 00:23:23 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
@@ -57,9 +57,8 @@ assign_datestyle(const char *value, bool doit, GucSource source)
5757/* syntax error in list */
5858pfree (rawstring );
5959list_free (elemlist );
60- if (source >=PGC_S_INTERACTIVE )
61- ereport (ERROR ,
62- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
60+ ereport (GUC_complaint_elevel (source ),
61+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
6362errmsg ("invalid list syntax for parameter \"datestyle\"" )));
6463return NULL ;
6564}
@@ -157,11 +156,10 @@ assign_datestyle(const char *value, bool doit, GucSource source)
157156}
158157else
159158{
160- if (source >=PGC_S_INTERACTIVE )
161- ereport (ERROR ,
162- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
163- errmsg ("unrecognized \"datestyle\" key word: \"%s\"" ,
164- tok )));
159+ ereport (GUC_complaint_elevel (source ),
160+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
161+ errmsg ("unrecognized \"datestyle\" key word: \"%s\"" ,
162+ tok )));
165163ok = false;
166164break ;
167165}
@@ -172,10 +170,9 @@ assign_datestyle(const char *value, bool doit, GucSource source)
172170
173171if (!ok )
174172{
175- if (source >=PGC_S_INTERACTIVE )
176- ereport (ERROR ,
177- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
178- errmsg ("conflicting \"datestyle\" specifications" )));
173+ ereport (GUC_complaint_elevel (source ),
174+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
175+ errmsg ("conflicting \"datestyle\" specifications" )));
179176return NULL ;
180177}
181178
@@ -271,9 +268,9 @@ assign_timezone(const char *value, bool doit, GucSource source)
271268
272269/*
273270 * Try to parse it. XXX an invalid interval format will result in
274- * ereport, which is not desirable for GUC. We did what we could to
275- * guard against this in flatten_set_variable_args, but a string
276- * coming in from postgresql.conf might contain anything.
271+ * ereport(ERROR) , which is not desirable for GUC. We did what we
272+ *could to guard against this in flatten_set_variable_args, but a
273+ *string coming in from postgresql.conf might contain anything.
277274 */
278275interval = DatumGetIntervalP (DirectFunctionCall3 (interval_in ,
279276CStringGetDatum (val ),
@@ -283,19 +280,17 @@ assign_timezone(const char *value, bool doit, GucSource source)
283280pfree (val );
284281if (interval -> month != 0 )
285282{
286- if (source >=PGC_S_INTERACTIVE )
287- ereport (ERROR ,
288- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
289- errmsg ("invalid interval value for time zone: month not allowed" )));
283+ ereport (GUC_complaint_elevel (source ),
284+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
285+ errmsg ("invalid interval value for time zone: month not allowed" )));
290286pfree (interval );
291287return NULL ;
292288}
293289if (interval -> day != 0 )
294290{
295- if (source >=PGC_S_INTERACTIVE )
296- ereport (ERROR ,
297- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
298- errmsg ("invalid interval value for time zone: day not allowed" )));
291+ ereport (GUC_complaint_elevel (source ),
292+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
293+ errmsg ("invalid interval value for time zone: day not allowed" )));
299294pfree (interval );
300295return NULL ;
301296}
@@ -361,7 +356,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
361356
362357if (!new_tz )
363358{
364- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
359+ ereport (GUC_complaint_elevel (source ) ,
365360(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
366361errmsg ("unrecognized time zone name: \"%s\"" ,
367362value )));
@@ -370,7 +365,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
370365
371366if (!tz_acceptable (new_tz ))
372367{
373- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
368+ ereport (GUC_complaint_elevel (source ) ,
374369(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
375370errmsg ("time zone \"%s\" appears to use leap seconds" ,
376371value ),
@@ -493,7 +488,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
493488
494489if (!new_tz )
495490{
496- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
491+ ereport (GUC_complaint_elevel (source ) ,
497492(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
498493errmsg ("unrecognized time zone name: \"%s\"" ,
499494value )));
@@ -502,7 +497,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
502497
503498if (!tz_acceptable (new_tz ))
504499{
505- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
500+ ereport (GUC_complaint_elevel (source ) ,
506501(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
507502errmsg ("time zone \"%s\" appears to use leap seconds" ,
508503value ),
@@ -557,22 +552,20 @@ assign_XactIsoLevel(const char *value, bool doit, GucSource source)
557552{
558553if (SerializableSnapshot != NULL )
559554{
560- if (source >=PGC_S_INTERACTIVE )
561- ereport (ERROR ,
562- (errcode (ERRCODE_ACTIVE_SQL_TRANSACTION ),
563- errmsg ("SET TRANSACTION ISOLATION LEVEL must be called before any query" )));
555+ ereport (GUC_complaint_elevel (source ),
556+ (errcode (ERRCODE_ACTIVE_SQL_TRANSACTION ),
557+ errmsg ("SET TRANSACTION ISOLATION LEVEL must be called before any query" )));
564558/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
565- else if (source != PGC_S_OVERRIDE )
559+ if (source != PGC_S_OVERRIDE )
566560return NULL ;
567561}
568- if (IsSubTransaction ())
562+ else if (IsSubTransaction ())
569563{
570- if (source >=PGC_S_INTERACTIVE )
571- ereport (ERROR ,
572- (errcode (ERRCODE_ACTIVE_SQL_TRANSACTION ),
573- errmsg ("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction" )));
564+ ereport (GUC_complaint_elevel (source ),
565+ (errcode (ERRCODE_ACTIVE_SQL_TRANSACTION ),
566+ errmsg ("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction" )));
574567/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
575- else if (source != PGC_S_OVERRIDE )
568+ if (source != PGC_S_OVERRIDE )
576569return NULL ;
577570}
578571
@@ -667,11 +660,10 @@ assign_client_encoding(const char *value, bool doit, GucSource source)
667660 */
668661if (SetClientEncoding (encoding ,doit )< 0 )
669662{
670- if (source >=PGC_S_INTERACTIVE )
671- ereport (ERROR ,
672- (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
673- errmsg ("conversion between %s and %s is not supported" ,
674- value ,GetDatabaseEncodingName ())));
663+ ereport (GUC_complaint_elevel (source ),
664+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
665+ errmsg ("conversion between %s and %s is not supported" ,
666+ value ,GetDatabaseEncodingName ())));
675667return NULL ;
676668}
677669return value ;
@@ -740,10 +732,9 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
7407320 ,0 ,0 );
741733if (!HeapTupleIsValid (roleTup ))
742734{
743- if (source >=PGC_S_INTERACTIVE )
744- ereport (ERROR ,
745- (errcode (ERRCODE_UNDEFINED_OBJECT ),
746- errmsg ("role \"%s\" does not exist" ,value )));
735+ ereport (GUC_complaint_elevel (source ),
736+ (errcode (ERRCODE_UNDEFINED_OBJECT ),
737+ errmsg ("role \"%s\" does not exist" ,value )));
747738return NULL ;
748739}
749740
@@ -853,10 +844,9 @@ assign_role(const char *value, bool doit, GucSource source)
8538440 ,0 ,0 );
854845if (!HeapTupleIsValid (roleTup ))
855846{
856- if (source >=PGC_S_INTERACTIVE )
857- ereport (ERROR ,
858- (errcode (ERRCODE_UNDEFINED_OBJECT ),
859- errmsg ("role \"%s\" does not exist" ,value )));
847+ ereport (GUC_complaint_elevel (source ),
848+ (errcode (ERRCODE_UNDEFINED_OBJECT ),
849+ errmsg ("role \"%s\" does not exist" ,value )));
860850return NULL ;
861851}
862852
@@ -870,11 +860,10 @@ assign_role(const char *value, bool doit, GucSource source)
870860 */
871861if (!is_member_of_role (GetSessionUserId (),roleid ))
872862{
873- if (source >=PGC_S_INTERACTIVE )
874- ereport (ERROR ,
875- (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
876- errmsg ("permission denied to set role \"%s\"" ,
877- value )));
863+ ereport (GUC_complaint_elevel (source ),
864+ (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
865+ errmsg ("permission denied to set role \"%s\"" ,
866+ value )));
878867return NULL ;
879868}
880869}