psql \echo strangeness with :variables

Поиск
Список
Период
Сортировка
Искать
От
Jerry Sievers
Тема
psql \echo strangeness with :variables
Дата
в 17:57:51
Msg-id
m3ejyjp2d8.fsf@prod01.jerrysievers.com
Список
Дерево обсуждения
psql \echo strangeness with :variables Jerry Sievers <jerry@jerrysievers.com>
Hello.  Today I used a shell call in psql to save the runtime date in
a psql variable and use this to dynamically create tables with date
encoded in table name.

For some reason however, the psql \echo command can't  expand the date
though it does expand in the calls to the backend.

See example below;

jsievers@jsievers#
= \set date `date '+%Y%m%d'`

jsievers@jsievers#
= \echo :date
20060524

jsievers@jsievers#
= \echo foo_:date
foo_:date   <--  Was expecting this to expand... see below

jsievers@jsievers#
= create table foo_:date();
CREATE TABLE

jsievers@jsievers#
= \dt
            List of relations
 Schema |     Name     | Type  |  Owner   
--------+--------------+-------+----------
 public | foo_20060524 | table | jsievers
(1 row)

Seems there's a bit of asymmetry in the way psql evaluates the
:variables.

FYI

-- 
-------------------------------------------------------------------------------
Jerry Sievers   305 854-3001 (home)     WWW ECommerce Consultant
                305 321-1144 (mobile	http://www.JerrySievers.com/
В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
От: Joel Alejandro Espinosa Carra
Дата:
Сообщение: Re: JDBC issue
FAQ