From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Craig Ringer <craig(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Logical decoding on standby |
Date: | 2016-12-23 12:48:39 |
Message-ID: | e3ce4edb-2521-3542-2596-c58034974bad@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12/22/2016 01:21 AM, Craig Ringer wrote:
>> + my @fields = ('plugin', 'slot_type', 'datoid', 'database',
>> 'active', 'active_pid', 'xmin', 'catalog_xmin', 'restart_lsn');
>> + my $result = $self->safe_psql('postgres', 'SELECT ' . join(', ',
>> @fields) . " FROM pg_catalog.pg_replication_slots WHERE slot_name =
>> '$slot_name'");
>> + $result = undef if $result eq '';
>> + # hash slice, see http://stackoverflow.com/a/16755894/398670 .
>> Couldn't this portion be made more generic? Other queries could
>> benefit from that by having a routine that accepts as argument an
>> array of column names for example.
> Yeah, probably. I'm not sure where it should live though - TestLib.pm ?
>
> Not sure if there's an idomatic way to pass a string (in this case
> queyr) in Perl with a placeholder for interpolation of values (in this
> case columns). in Python you'd pass it with pre-defined
> %(placeholders)s for %.
>
>
For direct interpolation of an expression, there is this slightly
baroque gadget:
my $str = "here it is @{[ arbitrary expression here ]}";
For indirect interpolation using placeholders, there is
my $str = sprintf("format string",...);
which works much like C except that the string is returned as a result
instead of being the first argument.
And as we always say, TIMTOWTDI.
cheers
andrew (japh)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2016-12-23 12:53:35 | Re: pgstattuple documentation clarification |
Previous Message | Robert Haas | 2016-12-23 12:37:09 | Re: Declarative partitioning vs. sql_inheritance |