Project

General

Profile

# Date Author Comment
12262 02/16/2014 11:08 PM Aaron Marcuse-Kubitza

schemas/vegbien.sql: materialize_query(): support schema-qualified tables. this requires escaping tables in calls to this function.

12260 02/16/2014 10:45 PM Aaron Marcuse-Kubitza

schemas/util.sql: added qual_name()

12251 02/16/2014 07:54 PM Aaron Marcuse-Kubitza

schemas/util.sql: use new util.debug_print_sql() instead of `RAISE NOTICE` to improve readability of the debug output (which is used throughout the runscripts)

12250 02/16/2014 07:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: added debug_print_sql()

12249 02/16/2014 07:31 PM Aaron Marcuse-Kubitza

schemas/util.sql: added raise_notice(), to allow NOTICEs to be raised in sql-language functions

12247 02/16/2014 05:55 PM Aaron Marcuse-Kubitza

schemas/util.sql: added rematerialize_view()

12245 02/16/2014 03:24 PM Aaron Marcuse-Kubitza

schemas/util.sql: schema(regtype), schema(regclass): use new schema(pg_namespace_oid oid)

12244 02/16/2014 03:22 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema(pg_namespace_oid oid)

12243 02/16/2014 03:15 PM Aaron Marcuse-Kubitza

schemas/util.sql: schema(regclass): use joins instead of nested SELECTs for consistency with schema(regtype)

12242 02/16/2014 03:08 PM Aaron Marcuse-Kubitza

schemas/util.sql: regenerated from DB, which reorders the functions

12241 02/16/2014 02:44 PM Aaron Marcuse-Kubitza

schemas/util.sql: table_name(): renamed to name(regclass) for consistency with other name(...) functions

12240 02/16/2014 02:28 PM Aaron Marcuse-Kubitza

schemas/util.sql: table_schema(): renamed to schema(regclass) for consistency with other schema(...) functions

12238 02/16/2014 06:45 AM Aaron Marcuse-Kubitza

schemas/util.sql: schema_ident(): renamed to schema_esc() for clarity

12236 02/16/2014 06:39 AM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_search_path()

12235 02/16/2014 02:14 AM Aaron Marcuse-Kubitza

schemas/*.sql: make sure every COMMENT starts and ends on its own line, so that it appears correctly in the formats it's most likely to be read in (ie. in the DDL export, not the COMMENT edit box in pgAdmin)

12234 02/15/2014 03:51 PM Aaron Marcuse-Kubitza

schemas/util.sql: added materialize_view()

12233 02/15/2014 03:46 PM Aaron Marcuse-Kubitza

schemas/util.sql: added table_name()

12232 02/15/2014 03:45 PM Aaron Marcuse-Kubitza

schemas/util.sql: table_schema(): removed unneeded STRICT, which prevents inlining

12231 02/15/2014 03:41 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: fix_array(): removed no longer accurate comment about effects of STRICT, which is no longer used

12230 02/15/2014 03:28 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: materialize_query(): 1st param should be named table_, not view_

12229 02/15/2014 02:50 PM Aaron Marcuse-Kubitza

schemas/util.sql: added drop_view()

12228 02/15/2014 02:46 PM Aaron Marcuse-Kubitza

schemas/util.sql: added materialize_query()

12222 02/14/2014 12:39 PM Aaron Marcuse-Kubitza

schemas/util.sql: ifnull(): use COALESCE instead, because it turns out that MySQL's IFNULL is just a special case of this

12218 02/14/2014 11:55 AM Aaron Marcuse-Kubitza

schemas/util.sql: added ifnull(), equivalent to MySQL's IFNULL (Postgres auto-lowercases the name)

12185 02/13/2014 02:23 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff_cols(): documented how to run EXPLAIN on the FULL JOIN query

12184 02/13/2014 02:14 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff_cols(): embed left_query/right_query directly in the main SQL statement, so that the query planner can take the sort order of the queries into account in planning the FULL JOIN (and where possible, use a fast merge join)

12181 02/13/2014 02:05 PM Aaron Marcuse-Kubitza

schemas/util.sql: added eval2col_pair()

12135 02/08/2014 02:21 PM Aaron Marcuse-Kubitza

schemas/util.sql: added functions for maintaining schema bundles, groups of schemas with a common prefix

12134 02/08/2014 04:26 AM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_bundle_get_schemas()

12133 02/07/2014 11:36 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_replace()

12132 02/07/2014 11:11 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_rm(), schema_rename()

12045 02/05/2014 05:51 AM Aaron Marcuse-Kubitza

schemas/util.sql: added diff_views()

12044 02/05/2014 05:31 AM Aaron Marcuse-Kubitza

schemas/util.sql: added diff_cols(), for use with the aggregating validations

11970 01/20/2014 11:33 AM Aaron Marcuse-Kubitza

moved everything into /trunk/ to create the standard svn layout, for use with tools that require this (eg. git-svn). IMPORTANT: do NOT do an `svn up`. instead, re-use your working copy's existing files with `svn switch` (http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.switch.html).

11836 12/05/2013 07:03 AM Aaron Marcuse-Kubitza

schemas/util.sql: explain2table(): documented usage:
PERFORM util.explain2table($$
query
$$);

11835 12/05/2013 05:52 AM Aaron Marcuse-Kubitza

schemas/util.sql: explain2table(): by default, use the util.explain table

11834 12/05/2013 05:49 AM Aaron Marcuse-Kubitza

schemas/util.sql: added explain table

11833 12/05/2013 05:47 AM Aaron Marcuse-Kubitza

schemas/util.sql: added explain2notice()

11832 12/05/2013 05:44 AM Aaron Marcuse-Kubitza

schemas/util.sql: added explain2str()

11831 12/05/2013 05:33 AM Aaron Marcuse-Kubitza

schemas/util.sql: added explain2table()

11830 12/05/2013 05:23 AM Aaron Marcuse-Kubitza

schemas/util.sql: added explain()

11695 11/18/2013 05:32 PM Aaron Marcuse-Kubitza

schemas/util.sql: added force_recreate(), for use by sync_analytical_stem_to_view(). this uses the new `GET STACKED DIAGNOSTICS` in PostgreSQL 9.3 to access the DETAIL section of the dependent_objects_still_exist error.

11667 11/14/2013 02:32 PM Aaron Marcuse-Kubitza

schemas/*.sql: updated for PostgreSQL 9.3. this reorders some functions, adds empty comment headers for omitted SEQUENCE SET commands, and (best of all) finally splits view columns onto multiple lines, so that changes in the columns are actually legible (and produce their own svn diff!)

11660 11/14/2013 02:59 AM Aaron Marcuse-Kubitza

schemas/util.sql: added save_drop_views()

11659 11/14/2013 02:37 AM Aaron Marcuse-Kubitza

schemas/util.sql: added is_empty(anyarray)

11657 11/14/2013 02:16 AM Aaron Marcuse-Kubitza

schemas/util.sql: added regexp_matches_group()

11656 11/14/2013 01:13 AM Aaron Marcuse-Kubitza

schemas/util.sql: show_create_view(): also include GRANT statements, which are necessary to fully re-create the view

11655 11/14/2013 12:54 AM Aaron Marcuse-Kubitza

schemas/util.sql: added show_grants_for(table_ regclass), for use by show_create_view()

11652 11/13/2013 08:35 PM Aaron Marcuse-Kubitza

schemas/util.sql: added save_drop_view()

11651 11/13/2013 08:33 PM Aaron Marcuse-Kubitza

schemas/util.sql: added show_create_view()

11011 09/19/2013 01:05 AM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_subset_by_row_num_func(regclass), which uses a sort_col instead of a row_num column

11010 09/19/2013 12:10 AM Aaron Marcuse-Kubitza

schemas/util.sql: mk_subset_by_row_num_func(): factored creation of no-sort subset function into mk_subset_by_row_num_no_sort_func() so it can be used by other functions

11005 09/18/2013 10:14 PM Aaron Marcuse-Kubitza

schemas/util.sql: added ||% operator to append to escaped strings (the % indicates an identifier, as in Perl hashes and one of the x86 assembler syntaxes for registers

10991 09/15/2013 01:27 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_subset_by_row_num_func(): need explicit ORDER BY on the row_num_col, to prevent PostgreSQL from sorting the rows in reverse (they will be sorted because of the index scan, but the direction is otherwise indeterminate)

10990 09/15/2013 01:20 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_subset_by_row_num_func(): support tables whose pkeys don't start with 1 (such as the VegBank tables), by calculating the smallest row_num from the table

10989 09/15/2013 01:03 PM Aaron Marcuse-Kubitza

schemas/util.sql: offset2row_num(), limit2row_num(): added optional min_row_num, for tables whose serial pkeys start from a value other than 1

10988 09/15/2013 12:36 PM Aaron Marcuse-Kubitza

schemas/util.sql: added qual_name(regclass)

10987 09/15/2013 08:36 AM Aaron Marcuse-Kubitza

schemas/util.sql: added esc_name__append()

10986 09/15/2013 08:09 AM Aaron Marcuse-Kubitza

schemas/util.sql: added col__min()

10985 09/15/2013 07:34 AM Aaron Marcuse-Kubitza

schemas/util.sql: added limit2row_num() and use it in mk_subset_by_row_num_func() for clarity

10984 09/15/2013 07:26 AM Aaron Marcuse-Kubitza

schemas/util.sql: added offset2row_num() and use it in mk_subset_by_row_num_func() for clarity

10795 08/29/2013 04:20 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_ident()

10794 08/29/2013 03:20 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema(regtype), schema(anyelement)

10715 08/22/2013 05:33 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: set_col_names_with_metadata(): rename any metadata cols rather than re-adding them with new names

10699 08/21/2013 06:50 PM Aaron Marcuse-Kubitza

schemas/util.sql: combining functions taking anyelement params which could be text: take text param instead, so that other argument types (e.g. integer) will first be implicitly cast to text instead of trying to concatenate integers directly. this fixes a bug in the VegBank.stemcount_,stemlocation_ _join() of two integer pkeys, which first needed to be cast to text. anyelement was previously used so that other text-like types such as varchar could also be used, but varchar is implicitly castable to text so keeping anyelement should not be necessary.

10613 08/07/2013 08:30 AM Aaron Marcuse-Kubitza

schemas/util.sql: added ?*>= operator (is populated more often than) from wiki.vegpath.org/Postgres_queries#is-populated-more-often-than

10608 08/07/2013 06:33 AM Aaron Marcuse-Kubitza

schemas/util.sql: hstore(text[], anyelement): replaced with just hstore(text[], text) so that bare literals (of type unknown) are auto-cast to text instead of causing a "could not determine polymorphic type because input has type "unknown"" error

10596 08/04/2013 06:06 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: reset_col_names(): remove metadata value columns from the map table entirely, so that they are not considered to be in the table (old-style import does not use metadata value columns, so there would be no column or a different column in the metadata value column's slot)

10595 08/04/2013 05:58 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: trim(): need to remove all added columns, not just derived columns, because metadata value columns are also added by new-style import and need to be removed to restore a staging table to its pre-new-style state

10594 08/04/2013 05:55 PM Aaron Marcuse-Kubitza

schemas/util.sql: added added_cols()

10593 08/04/2013 04:06 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: reset_col_names(): need to avoid renaming metadata value columns, because the "from" entry is a value, not a column name

10391 07/24/2013 01:09 PM Aaron Marcuse-Kubitza

schemas/util.sql: added ?>= operator with is_more_complete_than() function

10388 07/24/2013 11:18 AM Aaron Marcuse-Kubitza

schemas/util.sql: SQL-language IMMUTABLE functions marked STRICT: removed STRICT to enable dynamic inlining, which speeds up the function up to 7x. STRICT was not removed where the function was particularly complex and the STRICT optimization would likely be more significant than inlining.

10378 07/20/2013 05:21 AM Aaron Marcuse-Kubitza

schemas/util.sql: schema comment: added note that IMMUTABLE SQL-language functions should never be declared STRICT, because this prevents them from being inlined. inlining can create a significant speed improvement (7x+), by avoiding function calls and enabling additional constant folding.

10375 07/20/2013 04:37 AM Aaron Marcuse-Kubitza

schemas/util.sql: map_nulls(): documented that inputs/REMIB/Specimen/postprocess.sql > country also shows that inlining is now happening properly. note that the speed improvement due to inlining is not as much, %wise, when the values util._map() is run on are long strings instead of the short strings used in the initial profiling. this is because a greater % of the time is spent in system functions such as hstore>text, which are not affected by the inlining because they are run either way.

10374 07/20/2013 04:18 AM Aaron Marcuse-Kubitza

schemas/util.sql: map_nulls(): use new nulls_map(). proper inlining (i.e. same runtime before and after change) has been verified with the following profiling query:
SELECT util.map_nulls(array[1, 2, 3]::text[], v) FROM unnest(array_fill(1, array100000)) f (v)

10373 07/20/2013 04:05 AM Aaron Marcuse-Kubitza

schemas/util.sql: added nulls_map(), for use with _map()

10365 07/20/2013 02:57 AM Aaron Marcuse-Kubitza

schemas/util.sql: added trim(), which trims a table to include only original columns, as defined by a map table

10364 07/20/2013 02:53 AM Aaron Marcuse-Kubitza

schemas/util.sql: added derived_cols(), which gets table_'s derived columns (all the columns not in the names table)

10363 07/20/2013 02:29 AM Aaron Marcuse-Kubitza

schemas/util.sql: added eval2set()

10362 07/20/2013 02:14 AM Aaron Marcuse-Kubitza

schemas/util.sql: added drop_column()

10359 07/19/2013 07:05 PM Aaron Marcuse-Kubitza

schemas/util.sql: map_nulls(): documented that due to dynamic inlining, this is just as fast as util._map() which it wraps. dynamic inlining now brings altogether a 40x speed improvement to map_nulls() (4000 ms -> 100 ms), and would likely bring a comparable improvement for other functions that are run repeatedly and call other user-defined functions.

10358 07/19/2013 06:35 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: map_nulls(): updated to use hstore(text[], anyelement), which has replaced hstore(anyarray, anyelement)

10357 07/19/2013 06:30 PM Aaron Marcuse-Kubitza

schemas/util.sql: removed hstore(anyarray, anyelement), which did not support dynamic inlining, to avoid confusion over which hstore() function to use. use new hstore(text[], anyelement) instead (with explicit cast on the keys array if needed).

10356 07/19/2013 06:23 PM Aaron Marcuse-Kubitza

schemas/util.sql: added hstore(text[], anyelement), which dynamically inlines properly, unlike hstore(anyarray, anyelement). this can be selected by explicitly casting the keys array to text[], which now provides a 6x speed improvement (380 ms -> 60 ms) for map_nulls().

10355 07/19/2013 05:31 PM Aaron Marcuse-Kubitza

schemas/util.sql: fix_array(): turned off STRICT to allow dynamic inlining, which speeds up util.map_nulls() by 3x (1500 ms -> 500 ms)

10354 07/19/2013 05:15 PM Aaron Marcuse-Kubitza

schemas/util.sql: array_length(anyarray), array_length(anyarray, dimension integer): turned off STRICT to allow dynamic inlining, which speeds up util.map_nulls(). this requires adding a `CASE WHEN $1 IS NULL THEN NULL` statement to array_length(anyarray, dimension integer) to replace the functionality provided by STRICT.

10353 07/19/2013 04:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: map_nulls(): turned off STRICT to allow dynamic inlining, which causes a 2x speed improvement1. (see r10352 for an explanation of dynamic inlining.) note that turning off STRICT disables NULL-skipping (avoiding running a function when all its params are NULL), so it should only be used when the NULL-skipping optimization is needed less than dynamic inlining....

10352 07/19/2013 04:23 PM Aaron Marcuse-Kubitza

schemas/util.sql: inlinable IMMUTABLE functions: avoid using config params (e.g. `SET search_path TO util`) because these prevent dynamic inlining (i.e. inlining of a function call with variable instead of constant arguments, by substituting the arguments into the function's body). dynamic inlining can speed up function evaluation significantly, because a (slow) call to a user-defined SQL function is avoided.

10345 07/19/2013 09:54 AM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: set_col_names(): need to generate error if destination column already exists (rather than suppressing it with try_create()), because this indicates a collision

10343 07/19/2013 09:23 AM Aaron Marcuse-Kubitza

schemas/util.sql: map table: added unique constraint on the to column as well, because the destination names also need to be distinct in order to be a valid set of column names

10342 07/19/2013 09:14 AM Aaron Marcuse-Kubitza

schemas/util.sql: map table: changed pkey to a unique constraint so pgAdmin would sort the entries in table order (matching the order they are in the staging table) instead of alphabetized by the pkey

10329 07/19/2013 03:13 AM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: not_empty(anyarray): array_length() now refers to different functions, with different semantics, depending on whether util is in the search_path. this necessitates explicitly selecting util.array_length() and switching to its semantics (ARRAY[] -> 0 instead of NULL)

10328 07/19/2013 03:02 AM Aaron Marcuse-Kubitza

schemas/util.sql: map_nulls(): support all datatypes, not just text

10327 07/19/2013 02:55 AM Aaron Marcuse-Kubitza

schemas/util.sql: added hstore(keys anyarray, value anyelement) and => (anyarray, anyelement) operator to support other element types for hstore

10325 07/18/2013 04:31 PM Aaron Marcuse-Kubitza

schemas/util.sql: added map_nulls(), a common use case of _map()

10324 07/18/2013 04:29 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: hstore(keys text[], value text): use new fix_array() so that an empty keys array is made 1-dimensional to match up with the array generated by array_fill()

10323 07/18/2013 04:26 PM Aaron Marcuse-Kubitza

schemas/util.sql: added fix_array(), which ensures that the array will always have proper non-NULL dimensions

10322 07/18/2013 04:21 PM Aaron Marcuse-Kubitza

schemas/util.sql: added empty_array(), for constructing proper empty 1-dimensional arrays whose dimensions are not NULL ( {}::text[] does not do this)

10321 07/18/2013 03:36 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: array_length(anyarray): need to call util.array_length() instead of just array_length() (which uses pg_catalog.array_length()) so that empty arrays will be returned as 0 instead of NULL. note that for some reason, adding `SET search_path=util` to the function does not have the same effect.