Compare commits

...

12 Commits
0.3.6 ... 0.4.1

Author SHA1 Message Date
Kartones
c9ff282b17 CDB-4418 2014-10-21 16:37:59 +02:00
Kartones
f251e12d35 CDB-4418 2014-10-21 16:19:44 +02:00
Raul Ochoa
5a3b93fd6b Release 0.4.0 2014-08-27 14:34:37 +02:00
Raul Ochoa
eaee6d3d70 Merge pull request #53 from CartoDB/CDB-3504
New versioning mechanism
2014-08-25 17:12:57 +02:00
Raul Ochoa
7840e7c50b Prepares version 0.4.0 with new versioning mechanism 2014-08-25 12:00:45 +02:00
Raul Ochoa
5b0a7bf9ad Adds highlighting 2014-08-21 19:05:15 +02:00
Raul Ochoa
2ef6d5901e Fixes typos 2014-08-21 19:05:04 +02:00
Raul Ochoa
3d37b3646e Renames files to take advantage of markdown 2014-08-21 19:01:19 +02:00
Raul Ochoa
51d48c7629 CDB-3656 Removes revision from the extension version 2014-08-21 18:52:21 +02:00
Raul Ochoa
25a0e5ec68 Stubs next version 2014-08-21 18:41:09 +02:00
Raul Ochoa
daa61a6aa8 Merge pull request #52 from CartoDB/CDB-3483
Adds CDB_Math_Model
2014-08-21 17:48:36 +02:00
javi
723a08e814 added CDB_Math_mode 2014-08-19 18:09:27 +02:00
10 changed files with 70 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ in which those scripts are loaded.
Scripts would be best coded in a way to be usable both for creation
and upgrade of the objects. This means using CREATE OR REPLACE for
the functions, and whatever it takes to check existance of any previous
the functions, and whatever it takes to check existence of any previous
version of objects in other cases.
When used as an extension (probably always from version 0.2.0 onwards)
@@ -27,8 +27,8 @@ all the objects will be installed in a "cartodb" schema. Take this into
account to fully-qualify internal calls to avoid (possibly dangerous)
name clashes.
Every new feature (as well as bugfixes) should come with a testcase,
see next session.
Every new feature (as well as bugfixes) should come with a test case,
see next section.
Writing testcases
-----------------
@@ -58,4 +58,3 @@ Starting with 0.2.0, the in-place reload can be done with an ad-hoc function:
```sql
SELECT cartodb.cdb_extension_reload();
```

View File

@@ -1,7 +1,7 @@
# cartodb/Makefile
EXTENSION = cartodb
EXTVERSION = 0.3.6
EXTVERSION = 0.4.1
SED = sed
@@ -26,6 +26,8 @@ UPGRADABLE = \
0.3.3 \
0.3.4 \
0.3.5 \
0.3.6 \
0.4.0 \
$(EXTVERSION)dev \
$(EXTVERSION)next \
$(END)
@@ -36,7 +38,6 @@ UPGRADES = \
$(SED) 's/$$/--$(EXTVERSION).sql/' | \
$(SED) 's/ /--$(EXTVERSION).sql $(EXTENSION)--/g')
REV=$(shell git describe)
GITDIR=$(shell test -d .git && echo '.git' || cat .git | $(SED) 's/^gitdir: //')
DATA_built = \
@@ -78,7 +79,7 @@ $(EXTENSION).control: $(EXTENSION).control.in Makefile
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
cartodb_version.sql: cartodb_version.sql.in Makefile $(GITDIR)/index
$(SED) -e 's/@@VERSION@@/$(EXTVERSION) $(REV)/' $< > $@
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
legacy_regress: $(REGRESS_OLD) Makefile
mkdir -p sql/test/

View File

@@ -1,3 +1,8 @@
0.4.0 (2014-08-27)
------------------
Added CDB_Math_Mode function
Changes in versioning: no revision is attached so it no longer uses `git describe` for the version.
0.3.6 (2014-08-11)
------------------
Dummy release to solve some issues with cdb branch/tag

View File

@@ -20,12 +20,16 @@ Dependencies
Install
-------
make all install
```sh
make all install
```
Test installation
-----------------
make installcheck
```sh
make installcheck
```
NOTE: if ``test_ddl_triggers`` fails it's likely due to an incomplete
installation of schema_triggers: you need to add ``schema_triggers.so``

View File

@@ -67,6 +67,7 @@ DECLARE
had_column BOOLEAN;
i INTEGER;
new_name TEXT;
cartodb_id_name TEXT;
BEGIN
<< cartodb_id_setup >>
LOOP --{
@@ -75,6 +76,7 @@ BEGIN
sql := 'ALTER TABLE ' || reloid::text || ' ADD cartodb_id SERIAL NOT NULL UNIQUE';
RAISE DEBUG 'Running %', sql;
EXECUTE sql;
cartodb_id_name := 'cartodb_id';
EXIT cartodb_id_setup;
EXCEPTION
WHEN duplicate_column THEN
@@ -114,6 +116,7 @@ BEGIN
BEGIN
RAISE DEBUG 'Running %', sql;
EXECUTE sql;
cartodb_id_name := 'cartodb_id';
EXIT cartodb_id_setup;
EXCEPTION
WHEN unique_violation OR not_null_violation THEN
@@ -139,13 +142,14 @@ BEGIN
WHEN others THEN
RAISE EXCEPTION 'Cartodbfying % (renaming cartodb_id): % (%)', reloid, SQLERRM, SQLSTATE;
END;
cartodb_id_name := new_name;
EXIT rename_column;
END LOOP; --}
CONTINUE cartodb_id_setup;
END IF;
END LOOP; -- }
-- Try to copy data from new name if possible
-- Try to copy data from new name if possible
IF new_name IS NOT NULL THEN
RAISE NOTICE 'Trying to recover data from % column', new_name;
BEGIN
@@ -185,6 +189,18 @@ BEGIN
END;
END IF;
-- Set primary key of the table if not already present (e.g. tables created from SQL API)
IF cartodb_id_name IS NULL THEN
RAISE EXCEPTION 'Cartodbfying % (Didnt get cartodb_id field name)', reloid;
END IF;
BEGIN
sql := 'ALTER TABLE ' || reloid::text || ' ADD PRIMARY KEY (cartodb_id)';
EXECUTE sql;
EXCEPTION
WHEN others THEN
RAISE DEBUG 'Table % Already had PRIMARY KEY', reloid;
END;
END;
$$ LANGUAGE PLPGSQL;

View File

@@ -0,0 +1,26 @@
-- CartoDB Math SQL functions
-- Mode
-- https://wiki.postgresql.org/wiki/Aggregate_Mode
CREATE OR REPLACE FUNCTION cartodb._CDB_Math_final_mode(anyarray)
RETURNS anyelement AS
$BODY$
SELECT a
FROM unnest($1) a
GROUP BY 1
ORDER BY COUNT(1) DESC, 1
LIMIT 1;
$BODY$
LANGUAGE 'sql' IMMUTABLE;
DROP AGGREGATE IF EXISTS cartodb.CDB_Math_Mode(anyelement);
CREATE AGGREGATE cartodb.CDB_Math_Mode(anyelement) (
SFUNC=array_append,
STYPE=anyarray,
FINALFUNC=_CDB_Math_final_mode,
INITCOND='{}'
);

View File

@@ -0,0 +1 @@
../scripts-available/CDB_Math.sql

4
test/CDB_MathTest.sql Normal file
View File

@@ -0,0 +1,4 @@
SELECT cdb_math_mode(a) from unnest(ARRAY[1,2,2,3]) a;
SELECT cdb_math_mode(a) from unnest(ARRAY[1,2,3]) a;
SELECT cdb_math_mode(a) from unnest(ARRAY[1]) a;

3
test/CDB_MathTest_expect Normal file
View File

@@ -0,0 +1,3 @@
2
1
1

View File

@@ -7,7 +7,7 @@ ERROR: Quota exceeded by 3.9990234375KB
INSERT 0 1024
8
ERROR: Quota exceeded by 103.9921875KB
ERROR: Quota exceeded by 123.9921875KB
0
INSERT 0 1
DROP TABLE