9
9
*
10
10
*
11
11
* 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 $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
@@ -57,9 +57,8 @@ assign_datestyle(const char *value, bool doit, GucSource source)
57
57
/* syntax error in list */
58
58
pfree (rawstring );
59
59
list_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 ),
63
62
errmsg ("invalid list syntax for parameter \"datestyle\"" )));
64
63
return NULL ;
65
64
}
@@ -157,11 +156,10 @@ assign_datestyle(const char *value, bool doit, GucSource source)
157
156
}
158
157
else
159
158
{
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 )));
165
163
ok = false;
166
164
break ;
167
165
}
@@ -172,10 +170,9 @@ assign_datestyle(const char *value, bool doit, GucSource source)
172
170
173
171
if (!ok )
174
172
{
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" )));
179
176
return NULL ;
180
177
}
181
178
@@ -271,9 +268,9 @@ assign_timezone(const char *value, bool doit, GucSource source)
271
268
272
269
/*
273
270
* 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.
277
274
*/
278
275
interval = DatumGetIntervalP (DirectFunctionCall3 (interval_in ,
279
276
CStringGetDatum (val ),
@@ -283,19 +280,17 @@ assign_timezone(const char *value, bool doit, GucSource source)
283
280
pfree (val );
284
281
if (interval -> month != 0 )
285
282
{
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" )));
290
286
pfree (interval );
291
287
return NULL ;
292
288
}
293
289
if (interval -> day != 0 )
294
290
{
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" )));
299
294
pfree (interval );
300
295
return NULL ;
301
296
}
@@ -361,7 +356,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
361
356
362
357
if (!new_tz )
363
358
{
364
- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
359
+ ereport (GUC_complaint_elevel (source ) ,
365
360
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
366
361
errmsg ("unrecognized time zone name: \"%s\"" ,
367
362
value )));
@@ -370,7 +365,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
370
365
371
366
if (!tz_acceptable (new_tz ))
372
367
{
373
- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
368
+ ereport (GUC_complaint_elevel (source ) ,
374
369
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
375
370
errmsg ("time zone \"%s\" appears to use leap seconds" ,
376
371
value ),
@@ -493,7 +488,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
493
488
494
489
if (!new_tz )
495
490
{
496
- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
491
+ ereport (GUC_complaint_elevel (source ) ,
497
492
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
498
493
errmsg ("unrecognized time zone name: \"%s\"" ,
499
494
value )));
@@ -502,7 +497,7 @@ assign_log_timezone(const char *value, bool doit, GucSource source)
502
497
503
498
if (!tz_acceptable (new_tz ))
504
499
{
505
- ereport ((source >= PGC_S_INTERACTIVE ) ? ERROR : LOG ,
500
+ ereport (GUC_complaint_elevel (source ) ,
506
501
(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
507
502
errmsg ("time zone \"%s\" appears to use leap seconds" ,
508
503
value ),
@@ -557,22 +552,20 @@ assign_XactIsoLevel(const char *value, bool doit, GucSource source)
557
552
{
558
553
if (SerializableSnapshot != NULL )
559
554
{
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" )));
564
558
/* 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 )
566
560
return NULL ;
567
561
}
568
- if (IsSubTransaction ())
562
+ else if (IsSubTransaction ())
569
563
{
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" )));
574
567
/* 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 )
576
569
return NULL ;
577
570
}
578
571
@@ -667,11 +660,10 @@ assign_client_encoding(const char *value, bool doit, GucSource source)
667
660
*/
668
661
if (SetClientEncoding (encoding , doit ) < 0 )
669
662
{
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 ())));
675
667
return NULL ;
676
668
}
677
669
return value ;
@@ -740,10 +732,9 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
740
732
0 , 0 , 0 );
741
733
if (!HeapTupleIsValid (roleTup ))
742
734
{
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 )));
747
738
return NULL ;
748
739
}
749
740
@@ -853,10 +844,9 @@ assign_role(const char *value, bool doit, GucSource source)
853
844
0 , 0 , 0 );
854
845
if (!HeapTupleIsValid (roleTup ))
855
846
{
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 )));
860
850
return NULL ;
861
851
}
862
852
@@ -870,11 +860,10 @@ assign_role(const char *value, bool doit, GucSource source)
870
860
*/
871
861
if (!is_member_of_role (GetSessionUserId (), roleid ))
872
862
{
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 )));
878
867
return NULL ;
879
868
}
880
869
}
0 commit comments