Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Improve detail in pg tablespace creation
Browse files Browse the repository at this point in the history
  • Loading branch information
cataphract committed Aug 26, 2014
1 parent de3da86 commit 27ca3da
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ddl/postgres/GLOBAL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ $(TBDIR_TARGETS):
mkdir -p '$@'
@echo "The directory $@ was created, but I did not check whether its owner matches PostgreSQL system user"

tablespace_%: $(TABLESPACES)%
# sometimes the user can't know if the tablespace directory exists because he
# lacks execute permissions in one of parent directories of $(TABLESPACES) (the
# tablespaces directory). Therefore, make make look whether the directory exists
# only if we need to create the tablespace. We accomplish this by not making
# this rule not depend directly on $(TABLESPACES)% and instead call
# $(MAKE) $(TABLESPACES)$* at the last moment
tablespace_%:
test `$(PSQL_COMMAND) -c "select exists (select spcname from pg_tablespace where spcname = '$*')" -tA` \
= 't' || $(PSQL_COMMAND) -c "CREATE TABLESPACE $* LOCATION '$<'"
= 't' || { \
$(MAKE) $(TABLESPACES)$*; \
$(PSQL_COMMAND) -c "CREATE TABLESPACE $* LOCATION '$(TABLESPACES)$*'"; }

tablespaces: $(TB_TARGETS)

Expand Down

0 comments on commit 27ca3da

Please sign in to comment.