[GENERAL] How to assign default values to psql variables? - Mailing list pgsql-general

From Torsten Förtsch
Subject [GENERAL] How to assign default values to psql variables?
Date
Msg-id CAKkG4_m8xCWC6ZdpVEmFoLGDBt_XtTo_08F+Se2Q3+1=DnzgEA@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] How to assign default values to psql variables?  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
Hi,

I have a psql script relying on variables passed in on the command line with -v.

Is there any way to assign a default value in case the -v option is forgotten?

Here is an example with pgtap:

select diag('should be printed only in verbose mode') where :testverbose;

This can be called with -v testverbose=true or -v testverbose=false. However, if the assignment is forgotten, it breaks. I'd like to behave it as if testverbose=false was passed.

Thanks.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] bloat indexes - opinion
Next
From: Pavel Stehule
Date:
Subject: Re: [GENERAL] How to assign default values to psql variables?