Skip site navigation (1) Skip section navigation (2)

Re: control pg_hba.conf via SQL

From: David Fetter <david(at)fetter(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: control pg_hba.conf via SQL
Date: 2006-03-30 20:05:06
Message-ID: 20060330200506.GC14084@fetter.org (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, Mar 30, 2006 at 10:43:31AM -0500, Andrew Dunstan wrote:
> A.M. wrote:
> >Could postgres offer at least a read-only view of the data in the
> >interim?  Ordering could be controlled by line number.
> 
> You can get the contents as a single text field like this:
> 
> |  select pg_read_file|('pg_hba.conf', 0, 50*1024);
> 
> Writing a plperl function that would strip comments and blank lines
> and return the rest as a numbered set of lines would be fairly
> trivial.

You don't even need PL/Perl :)

SELECT * FROM (
    SELECT
        s.t AS "Ordering",
        (string_to_array(pg_read_file(
            'pg_hba.conf',
            0,
            (pg_stat_file('pg_hba.conf')).size
        ), '\n'))[s.t] AS "Line"
    FROM
        generate_series(
            1,
            array_upper(
                string_to_array(pg_read_file(
                    'pg_hba.conf',
                    0,
                    (pg_stat_file('pg_hba.conf')).size
                ), '\n'),
                1
            )
        ) AS s(t)
) AS foo
WHERE
    "Line" !~ '^#'
AND
    "Line" !~ '^\s*$'
;

Cheers,
D
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!

In response to

Responses

pgsql-hackers by date

Next:From: Andrew DunstanDate: 2006-03-30 22:17:38
Subject: Re: Tru64/Alpha problems
Previous:From: Robert TreatDate: 2006-03-30 19:49:49
Subject: Re: control pg_hba.conf via SQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group