Re: Make for PgSQL?

Поиск
Список
Период
Сортировка
От Reece Hart
Тема Re: Make for PgSQL?
Дата
Msg-id 1180619035.4513.21.camel@snafu.site
обсуждение исходный текст
Ответ на Make for PgSQL?  (Vincenzo Romano <vincenzo.romano@gmail.com>)
Ответы Re: Make for PgSQL?  (Vincenzo Romano <vincenzo.romano@gmail.com>)
Список pgsql-general
On Thu, 2007-05-31 at 09:01 +0200, Vincenzo Romano wrote:
> Scripts have been named so that the lexicographical order of filenames
> brings
> the information about dependencies.
>
> I've been playing with the GNU Make itself but it's quite hard to keep
> track
> of changes and to re-load a single SQL file that changed.

Expressing the dependencies is the hardest part. Once you have the
dependencies, the make part ought to be straightforward (except for
learning the bugaboos of make). "Keeping track of the changes" might
look something like this make snippet:

.DELETE_ON_ERROR:
.SUFFIXES:
%.log: %.sql
    psql ... -f $< >$@

(Bless the pg folks with mountains of chocolate and mountain dew for
returning meaningful exit codes even for DDL changes, as opposed to,
say, sqlplus.)

The you need to express your dependencies in a way that make can
understand. The most general way to do this is with a list like:

common.log: utils.log
fx1.log: common.log utils.log
fx2.log: fx1.log
etc.

Finally, you'll want a list of all log targets so that you can type
something like "make update" or whatever to reload as needed. You can
get that with, for example:

SQL_FILES:=$(wildcard sqldir/*.sql)
TARGETS:=$(SQL_FILES:.sql=.log)
.PHONY: update
update: ${TARGETS}


> Is there any hint about "best prectices", software tools and the
> likes?

I don't know anything about best practices (ahem). However, it occurs to
me that it wouldn't be hard to move your dependency encoding into the
SQL itself, such as

-- requires: utils.sql common.sql
create or replace function ...

Then you'd automatically generate a file of sql dependencies using a
perl one-liner (or whatever).

-Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0


В списке pgsql-general по дате отправления:

Предыдущее
От: "Bhavana.Rakesh"
Дата:
Сообщение: Re: jdbc pg_hba.conf error
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: jdbc pg_hba.conf error