March 10th, 2008 by depesz | Tags: , | 1 comment »
Did it help? If yes - maybe you can help me? Donate BTC to 19zPa5diT2LZqGtTi8f8bfApLn8rw9zBHx

today (2008-03-10) magnus hagander commited patch which adds new, quite handy functionality: “enum type for guc parameters".

commit message says quite a lot:

Log Message:
-----------
Implement enum type for guc parameters, and convert a couple of existing
variables to it. More need to be converted, but I wanted to get this in
before it conflicts with too much...
 
Other than just centralising the text-to-int conversion for parameters,
this allows the pg_settings view to contain a list of available options
and allows an error hint to show what values are allowed.

(copy of mail here).

what does it do?

let's see how things worked earlier (8.3):

template1=# select * from pg_settings where name = 'log_min_error_statement';
-[ RECORD 1 ]-------------------------------------------------------------------------------------------
name | log_min_error_statement
setting | error
unit |
category | Reporting and Logging / When to Log
short_desc | Causes all statements generating error at or above this level to be logged.
extra_desc | All SQL statements that cause an error of the specified level or a higher level are logged.
context | superuser
vartype | string
source | default
min_val |
max_val |

this is one of configuration variables which use new enum type. as you can see we know that it contains “error" value, but we dont know what other possibilities are there.

how will that look in 8.4 ?

# select * from pg_settings where name = 'log_min_error_statement';
-[ RECORD 1 ]----------------------------------------------------------------------------------------------
name | log_min_error_statement
setting | error
unit | [null]
category | Reporting and Logging / When to Log
short_desc | Causes all statements generating error at or above this level to be logged.
extra_desc | All SQL statements that cause an error of the specified level or a higher level are logged.
context | superuser
vartype | enum
source | default
min_val | [null]
max_val | [null]
enumvals | debug, debug5, debug4, debug3, debug2, debug1, log, info, notice, warning, error, fatal, panic

but, what's even more important, it will also work in case when trying to set bad value.

8.3:

template1=# set log_min_error_statement = 'bad value';
ERROR: invalid value for parameter "log_min_error_statement": "bad value"

while, in 8.4 it shows:

# set log_min_error_statement = 'bad value';
ERROR: invalid value for parameter "log_min_error_statement": "bad value"
HINT: Available values: debug, debug5, debug4, debug3, debug2, debug1, log, info, notice, warning, error, fatal, panic.

now, that's cool.

  1. One comment

  2. Mar 13, 2008

    Yep, that’s definitely cool.

    Wonder how many years it’ll take for Oracle’s command line parser to catch up…? ;->

Leave a comment