Add cdb_version() function

This commit is contained in:
Sandro Santilli 2014-05-08 10:07:47 +02:00
parent b8e15dba83
commit 5d3c63b964
3 changed files with 13 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
cartodb--*.sql
cartodb_version.sql
cartodb.control
results/
regression.*

View File

@ -10,7 +10,8 @@ CDBSCRIPTS = \
DATA_built = \
$(EXTENSION)--$(EXTVERSION).sql \
$(EXTENSION)--unpackaged--$(EXTVERSION).sql \
$(EXTENSION).control
$(EXTENSION).control \
cartodb_version.sql.in
DOCS = README.md
REGRESS_NEW = test_ddl_triggers
@ -22,13 +23,14 @@ PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
$(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_hooks.sql Makefile
$(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_hooks.sql cartodb_version.sql Makefile
: > $@
cat $(CDBSCRIPTS) | \
sed -e 's/\<public\./cartodb./g' \
-e 's/:DATABASE_USERNAME/cdb_org_admin/g' >> $@
echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@
cat cartodb_hooks.sql >> $@
cat cartodb_version.sql >> $@
$(EXTENSION)--unpackaged--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql util/create_from_unpackaged.sh Makefile
./util/create_from_unpackaged.sh $(EXTVERSION)
@ -36,6 +38,9 @@ $(EXTENSION)--unpackaged--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql uti
$(EXTENSION).control: $(EXTENSION).control.in
sed -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
cartodb_version.sql: cartodb_version.sql.in
sed -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
legacy_regress: $(REGRESS_OLD) Makefile
mkdir -p sql/test/
mkdir -p expected/test/

5
cartodb_version.sql.in Normal file
View File

@ -0,0 +1,5 @@
CREATE OR REPLACE FUNCTION cartodb.CDB_version()
RETURNS text AS $$
SELECT '@@VERSION@@'::text;
$$ language 'sql' IMMUTABLE STRICT;