dbTalk Databases Forums  

8.3 and current_setting() of unset variables.

comp.databases.postgresql comp.databases.postgresql


Discuss 8.3 and current_setting() of unset variables. in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Guettler
 
Posts: n/a

Default 8.3 and current_setting() of unset variables. - 12-14-2007 , 07:40 AM






Hi,

Postgres 8.3 behaves different, if you access an unset
custom variable. Version 8.1 returned 'unset', while 8.3 fails:

plpython trigger:

CREATE OR REPLACE FUNCTION get_or_create_transaction_id() returns INT as $$
transaction_id=plpy.execute("SELECT current_setting('modwork.transaction_id') AS id")[0]['id']
if not transaction_id or transaction_id=='unset':
# First write, create transaction ID

ProgrammingError: unrecognized configuration parameter 'modwork.transaction_id'

PostgreSQL 8.1.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.0 (SUSE Linux)
modwork_esg=# SHOW modwork.asfd;
modwork.asfd
--------------
unset


PostgreSQL 8.3beta3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.3.4 (pre 3.3.5 20040809)
modwork_esg=# SHOW modwork.asdf;
ERROR: unrecognized configuration parameter "modwork.asdf"


How can you check if a variable exists with 8.3?

BTW: current_setting() is not in the index:
http://www.postgresql.org/docs/8.3/s...bookindex.html

Reply With Quote
  #2  
Old   
petersprc
 
Posts: n/a

Default Re: 8.3 and current_setting() of unset variables. - 12-16-2007 , 07:17 PM






Hi,

There's the pg_settings table:

select setting from pg_catalog.pg_settings where name =
'modwork.transaction_id'

Or you could catch the syntax_error_or_access_rule_violation exception
raised by current_setting.

On Dec 14, 8:40 am, Thomas Guettler <h... (AT) tbz-pariv (DOT) de> wrote:
Quote:
Hi,

Postgres 8.3 behaves different, if you access an unset
custom variable. Version 8.1 returned 'unset', while 8.3 fails:

plpython trigger:

CREATE OR REPLACE FUNCTION get_or_create_transaction_id() returns INT as $$
transaction_id=plpy.execute("SELECTcurrent_setting ('modwork.transaction_id') AS id")[0]['id']
if not transaction_id or transaction_id=='unset':
# First write, create transaction ID

ProgrammingError: unrecognized configuration parameter 'modwork.transaction_id'

PostgreSQL8.1.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.0 (SUSE Linux)
modwork_esg=# SHOW modwork.asfd;
modwork.asfd
--------------
unset

PostgreSQL8.3beta3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.3.4 (pre 3.3.5 20040809)
modwork_esg=# SHOW modwork.asdf;
ERROR: unrecognized configuration parameter "modwork.asdf"

How can you check if a variable exists with 8.3?

BTW:current_setting() is not in the index:http://www.postgresql.org/docs/8.3/s...bookindex.html


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.