schemas/util.sql: added bounding_box()
schemas/util.sql: range(numeric, numeric): use simpler numrange() constructor instead of text input syntax
schemas/util.sql: operator functions: renamed to plain-text names to follow the Postgres convention of making the function name be the human-readable name of the operator
schemas/util.sql: added ~ operator for ranges
fix: schemas/util.sql: view_def_to_orig(): also need to merge .* expressions resulting from a SELECT * of a join, to avoid duplicated columns
fix: schemas/util.sql: view_def_to_orig(): require at least 6 cols to avoid false positives in the expansion match pattern
bugfix: schemas/util.sql: view_def_to_orig(): 1st col: can't prepend \y because it considers only \w chars, not "
bugfix: schemas/util.sql: view_def_to_orig(): don't match whitespace in the middle of a "" identifier, as this could throw off the parser
schemas/util.sql: eval(): restore user's intent by running util.view_def_to_orig() on the query to unexpand expanded * expressions
schemas/util.sql: pg_get_viewdef(): use util.view_def_to_orig()
schemas/util.sql: added view_def_to_orig()
fix: schemas/util.sql: pg_get_viewdef(): should be STABLE because it references system catalogs
schemas/util.sql: added pg_get_viewdef() wrapper, which unexpands expanded * expressions
bugfix: schemas/util.sql: mk_drop_from_create(): need to match first rather than last CREATE
schemas/util.sql: recreate_view(): support omitting the view_query if the view has already been modified (eg. for public.*_view, which allow changing the view as a separate step)
bugfix: schemas/util.sql: recreate(): need to handle case where util.mk_drop_from_create() is NULL
bugfix: schemas/util.sql: mk_drop_from_create(): only match CREATE if no custom DROP came before it
fix: schemas/util.sql: explain2notice_msg_if_can(): also need to catch invalid_cursor_definition ("cannot open multi-query plan as cursor")
schemas/util.sql: added copy()
schemas/util.sql: added copy_data()
schemas/util.sql: added seq__reset()
schemas/util.sql: added seq__create()
fix: schemas/util.sql: try_cast(), is_castable(): also catch invalid_schema_name, thrown by `'pg_temp.__'::regclass`
fix: schemas/util.sql: mk_drop_from_create(): also support CREATE queries that include the SELECT statement on the same line as the CREATE
schemas/util.sql: create_if_not_exists(): print message if already exists, so the function doesn't inexplicably appear not to have run at all
schemas/util.sql: added recreate_view(), a special case of util.recreate()
fix: schemas/util.sql: recreate(): usage: use `schema` instead of `schemas`
schemas/util.sql: recreate(): perform the correct DROP VIEW in the function itself so that the caller does not have to worry about forming it properly
bugfix: schemas/util.sql: mk_drop_from_create(): added `DROP`
schemas/util.sql: added mk_drop_from_create()
schemas/util.sql: added regexp_match()
fix: schemas/util.sql: force_recreate(): renamed to just recreate(), because "force" normally implies that things will be deleted, which this function does not do
schemas/util.sql: show_create_view(): use new mk_set_relation_metadata()
schemas/util.sql: added mk_set_relation_metadata()
schemas/util.sql: force_recreate(): documented usage, which is somewhat complex and has several important parts
bugfix: schemas/util.sql: restore_views(): need to specify view name for a manual existence check, in case the view definition becomes invalid, which would produce a nonstandard (uncatchable) exception
bugfix: schemas/util.sql: explain(): don't display any log messages printed by IMMUTABLE functions in the query, which EXPLAIN apparently runs
schemas/util.sql: create_if_not_exists(): added relation param, which can be used to ensure that a standard exception is always generated if the relation exists, even if the table definition would be invalid (which generates a variety of exceptions)
bugfix: schemas/util.sql: try_cast(), is_castable(): also need to handle syntax_error_or_access_rule_violation, which is thrown by ::regclass
schemas/util.sql: added relation_exists()
schemas/util.sql: save_drop_views()/restore_views(): store the view path in addition to the definition so it can be used in restoring
bugfix: schemas/util.sql: in_reverse(): can't use `SELECT *` for composite types because this expands them
bugfix: schemas/util.sql: array_reverse(): can't use `SELECT *` for composite types because this expands them
schemas/util.sql: save_drop_views()/restore_views(): use opaque return type so it can be changed without changing the local var type in functions that use this
schemas/util.sql: force_recreate(): recreate_users_cmds: renamed to restore_views_info since this is now whatever is needed by util.restore_views()
schemas/util.sql: added restore_views() and use it in force_recreate()
bugfix: schemas/util.sql: save_drop_views(): views must be dropped in reverse dependency order, but returned in forward dependency order
bugfix: schemas/util.sql: force_recreate(): dependent views need to be re-created in forward dependency order. this is done by reversing the dependencies only for save_drop_views().
bugfix: schemas/util.sql: mk_set_comment(): need to use VIEW instead of TABLE for views
bugfix: schemas/util.sql: show_create_view(): also need to include view comment
fix: schemas/util.sql: mk_set_comment(): added ;
fix: schemas/util.sql: show_set_comment(): don't display a COMMENT ON statement if no comment, because this will be appended to table defs, etc. and would create clutter
bugfix: schemas/util.sql: mk_set_comment(): need to handle NULL comment properly
schemas/util.sql: added show_set_comment(regclass)
schemas/util.sql: set_comment(): use util.mk_set_comment()
schemas/util.sql: added mk_set_comment()
bugfix: schemas/util.sql: force_recreate(): recreate_users_cmds: use create_if_not_exists() rather than eval(), because cmd might manually re-create a deleted dependent view, causing it to already exist
bugfix: schemas/util.sql: save_drop_view(): util.show_create_view(): don't include `OR REPLACE` because that causes nonuniform errors (eg. invalid_table_definition), instead of the standard duplicate_table exception caught by util.create_if_not_exists()
fix: schemas/util.sql: show_create_view(): removed extra trailing ; because pg_get_viewdef() now includes one
schemas/util.sql: show_create_view(): made inclusion of `OR REPLACE` configurable
schemas/util.sql: save_drop_view(): use util.drop_view()
schemas/util.sql: save_drop_views(): return text[] instead of concatenated text so that the queries will be run individually and be easier to debug
schemas/util.sql: added eval(queries text[])
bugfix: schemas/util.sql: force_recreate(): need to drop users in reverse to avoid dependencies that block the drop
schemas/util.sql: added array_reverse()
schemas/util.sql: added in_reverse()
bugfix: schemas/util.sql: force_recreate(): need to use :lower:, not [:lower:]
schemas/util.sql: force_recreate(): debug-print PG_EXCEPTION_DETAIL, users to assist in debugging
fix: schemas/util.sql: debug_print_value(): added trailing newline to visually distinguish the printed value
schemas/util.sql: added debug_print_var()
schemas/util.sql: debug_print_return_value(): use new util.debug_print_value()
schemas/util.sql: added debug_print_value()
fix: schemas/util.sql: util.force_recreate(): also support dropping things besides tables
bugfix: schemas/util.sql: explain2notice_msg_if_can(): don't use util.is_explainable() because the list provided by Postgres (http://www.postgresql.org/docs/9.3/static/sql-explain.html#AEN77691) excludes some query types that are in fact EXPLAIN-able
bugfix: schemas/util.sql: materialize_query(): contents generated from: need to include search_path so query is runnable
schemas/util.sql: added loop_ignore_errors()
schemas/util.sql: added _km_to_m() for use when public._km_to_m() is not defined yet
bugfix: schemas/util.sql: is_castable(): need to pass NULL through, for proper NULL propagation
schemas/util.sql: added is_castable()
schemas/util.sql: added try_cast()
schemas/util.sql: added util.cast(), which allows casting to an arbitrary type without eval()
bugfix: schemas/util.sql: remake_diff_table(): need to rm_freq() type_table, because left/right_table don't have freq yet
schemas/util.sql: auto_rm_freq(): use new rm_freq()
schemas/util.sql: added rm_freq(regclass[])
schemas/util.sql: remake_diff_table(): result table comment: documented how to display NULL values that are extra or missing
fix: schemas/util.sql: trim(): by default, cascadingly drop dependent columns so that they don't prevent trim() from succeeding. note that this requires the dependent columns to then be manually re-created.
bugfix: schemas/util.sql: is_constant(util.col_ref): updated to include standard newline at beginning of comment (applies to newly-imported staging tables)
fix: schemas/util.sql: explain2notice_msg(): don't include EXPLAIN output for simple, single-value queries, to avoid cluttering up the log output
schemas/util.sql: added fold_explain_msg()
bugfix: schemas/util.sql: set_col_types(): need to COALESCE the executed SQL to '' because util.eval() does not support NULL (and shouldn't, because this indicates a missing COALESCE in constructing the statement)
schemas/util.sql: set_col_types(): use simpler util.eval() instead of manual EXECUTE/util.debug_print_sql()
schemas/util.sql: set_col_types(): use string_agg() instead of array_to_string(ARRAY) for clarity
schemas/util.sql: added mk_not_null()
bugfix: drop_column(regclass[]): need to run `SELECT NULL::void;` at end of function to avoid folding away functions called in previous query
fix: schemas/util.sql: diff(regclass, regclass): moved try_create() of copies column in parent table to auto_rm_freq() so that it would only happen if both tables actually contain a copies column (otherwise, the try_create() will create an empty copies column if both tables are empty)
schemas/util.sql: try_create(): also handle "child table is missing column" errors
schemas/util.sql: added coalesce(anyarray), which can be used to force evaluation of all values of a COALESCE
schemas/util.sql: EXCEPTION blocks with multiple exception types: use OR to merge exception types into one WHEN block
schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): indicate in the type comment that the keys() type is autogenerated, so it can be distinguished from custom keys() types when bulk-regenerating keys() types
bugfix: schemas/util.sql: show_relations_like(): also need to include composite types, as these are also relations (and are expected to be included by callers of show_relations_like())