Project

General

Profile

# Date Author Comment
12664 03/12/2014 05:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: removed no longer used to_freq(regclass, drop_if_always_1). use to_freq(regclass) and auto_rm_freq() instead.

12663 03/12/2014 05:40 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: diff(regclass, regclass): only drop freq column if all tables have all 1s

12662 03/12/2014 05:38 PM Aaron Marcuse-Kubitza

schemas/util.sql: auto_rm_freq(): accept multiple tables, so the freq column is only dropped if all tables have all 1s

12661 03/12/2014 05:36 PM Aaron Marcuse-Kubitza

schemas/util.sql: added freq_always_1(regclass[])

12660 03/12/2014 05:35 PM Aaron Marcuse-Kubitza

schemas/util.sql: added drop_column(regclass[])

12659 03/12/2014 05:04 PM Aaron Marcuse-Kubitza

schemas/util.sql: added parent(regclass)

12658 03/12/2014 04:48 PM Aaron Marcuse-Kubitza

schemas/util.sql: try_create(): also handle not_null_violation, which is thrown when trying to add a NOT NULL column to a parent table, which cascades to a child table whose values for the new column will be NULL

12657 03/12/2014 04:44 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: diff(text, text): also need to cast left_/right_ to base type for the IS DISTINCT FROM filter, because the WHERE clause apparently does not use columns from the SELECT list, even though GROUP BY and ORDER BY do

12656 03/12/2014 04:13 PM Aaron Marcuse-Kubitza

schemas/util.sql: added to_freq(regclass, drop_if_always_1)

12655 03/12/2014 04:04 PM Aaron Marcuse-Kubitza

schemas/util.sql: added auto_rm_freq(regclass)

12654 03/12/2014 03:53 PM Aaron Marcuse-Kubitza

schemas/util.sql: added freq_always_1(regclass)

12653 03/12/2014 03:00 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: diff(regclass, regclass): need to create a diff when the # of copies of a row differs between the tables. this uses new util.to_freq().

12652 03/12/2014 02:44 PM Aaron Marcuse-Kubitza

schemas/util.sql: added to_freq(regclass)

12651 03/12/2014 02:43 PM Aaron Marcuse-Kubitza

schemas/util.sql: added populate_table(regclass, text)

12649 03/12/2014 12:53 PM Aaron Marcuse-Kubitza

schemas/util.sql: added copy_types_and_data(regclass, text)

12595 03/06/2014 12:00 AM Aaron Marcuse-Kubitza

schemas/util.sql: create_if_not_exists(): also support `CREATE FUNCTION` (by handling duplicate_function exceptions)

12594 03/05/2014 11:53 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_keys_func(): create the keys() function directly from the keys record type, to support creating just a custom keys record type rather than also a custom keys() function (which is fairly complicated to do, thanks to the need to define a separate custom return type)

12593 03/05/2014 01:01 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: relation_type(relation_type_char "char"): need to handle TYPEs as well, because these are also listed in pg_class (and should be deleted by drop_relations_like())

12592 03/05/2014 12:50 PM Aaron Marcuse-Kubitza

schemas/util.sql: added show_types_like()

12591 03/05/2014 12:42 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: functions marked IMMUTABLE: changed to STABLE or VOLATILE where IMMUTABLE would cause preemptive inlining (http://vegpath.org/links/#PostgreSQL:%20Documentation:%209.3:%20Function%20Volatility%20Categories%20**)

12590 03/05/2014 12:25 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: functions marked IMMUTABLE: changed to STABLE or VOLATILE where IMMUTABLE would cause preemptive inlining (http://vegpath.org/links/#PostgreSQL:%20Documentation:%209.3:%20Function%20Volatility%20Categories%20**)

12588 03/05/2014 07:28 AM Aaron Marcuse-Kubitza

schemas/util.sql: added relation_type(regtype) so drop_relation() would work on TYPEs, too. TYPEs are sometimes used as a function return type linked to a particular table (eg. in the keys() functions), and should be dropped along with the table by util.drop_relations_like().

12587 03/05/2014 07:24 AM Aaron Marcuse-Kubitza

schemas/util.sql: drop_relation(regclass): support any type that has a util.relation_type()

12581 03/04/2014 05:52 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): use `CREATE FUNCTION` instead of `CREATE OR REPLACE FUNCTION` so that the function is only created if it does not exist, to avoid overwriting a custom keys() function

12579 03/04/2014 05:47 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: uses of util.col_cast.col_name: need to wrap in quote_ident()

12577 03/04/2014 05:39 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): use named return type to avoid complicated edge cases with 1-column records, which prevent (values_(...)).* from working correctly

12576 03/04/2014 05:22 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_typed_cols_list(col_cast[])

12575 03/04/2014 05:20 PM Aaron Marcuse-Kubitza

schemas/util.sql: added prefixed_name()

12574 03/04/2014 05:18 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): use util.qual_name() to create the function name, for clarity

12572 03/04/2014 04:53 PM Aaron Marcuse-Kubitza

schemas/util.sql: util.remake_diff_table(): viewing the table in human-readable form: use just the output side's values_() columns, to avoid repeating columns on both sides that are the same and put just the changed columns side-by-side

12571 03/04/2014 04:45 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_keys_func(regtype): values() function: must be called values_() instead because `values` is a keyword

12570 03/04/2014 04:31 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_keys_func(regtype): also add values() function for use in displaying the diff table

12569 03/04/2014 04:19 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_keys_func(regtype, col_cast[]): allow changing the name of the generated function

12568 03/04/2014 03:55 PM Aaron Marcuse-Kubitza

schemas/util.sql: `RAISE USING ERRCODE = SQLSTATE, MESSAGE = SQLERRM`: use simpler `RAISE` to rethrow error

12567 03/04/2014 03:53 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): use util.create_if_not_exists() to avoid trying to overwrite a custom keys() function the user has written

12565 03/04/2014 03:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): automatically create a keys() function for the base type. this avoids the need to create keys() functions manually for the numerous queries that need them.

12564 03/04/2014 03:35 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_keys_func(regtype)

12563 03/04/2014 03:34 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): need to handle 1-column records specially, because Postgres does not allow returning a 1-column record when there are OUT params

12562 03/04/2014 03:02 PM Aaron Marcuse-Kubitza

schemas/util.sql: added typed_cols(regtype)

12561 03/04/2014 02:29 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_keys_func(regtype, col_cast[])

12560 03/04/2014 02:27 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: raise(): need to use $__BODY1$ in case msg contains $BODY1$ (in SQL)

12559 03/04/2014 02:23 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: mk_out_params(): need COALESCE around string_agg()

12558 03/04/2014 02:22 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: eval(): don't declare it STRICT because it should throw an error if you try to execute NULL

12556 03/04/2014 01:59 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_out_params()

12555 03/04/2014 01:42 AM Aaron Marcuse-Kubitza

schemas/util.sql: mk_diff_query(): indented left_ table to line up vertically with right_, for easier comparison of the left_/right_ table names

12554 03/04/2014 01:40 AM Aaron Marcuse-Kubitza

schemas/util.sql: mk_diff_query(): removed special handling for CROSS JOIN because this is now handled by diff(text, text) using `FULL JOIN ON true`. this simplification allows mk_diff_query() to contain just the template structure of the FULL JOIN, without _if() calls that decrease readability.

12553 03/04/2014 01:34 AM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): handle the CROSS JOIN special case using `FULL JOIN ON true`, to allow mk_diff_query() to support just a straighforward FULL JOIN. this also ensures that all diff queries use the same FULL JOIN template.

12536 02/27/2014 07:49 PM Aaron Marcuse-Kubitza

schemas/util.sql: raise_error_notice(): raise a WARNING instead because this is for errors, and rename to raise_error_warning() to match

12535 02/27/2014 07:45 PM Aaron Marcuse-Kubitza

schemas/util.sql: removed no longer used raise_notice(). use util.raise(NOTICE, ...) instead.

12534 02/27/2014 07:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: use util.raise(NOTICE, ...) instead of util.raise_notice()

12533 02/27/2014 07:37 PM Aaron Marcuse-Kubitza

schemas/util.sql: raise(type text, msg text): documented the possible options for the type param

12532 02/27/2014 07:34 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: raise(): util.eval(): turn off verbose_ mode to avoid printing debug statements about debug statements

12531 02/27/2014 07:32 PM Aaron Marcuse-Kubitza

schemas/util.sql: eval(): added verbose_ option like for eval2set()

12530 02/27/2014 07:28 PM Aaron Marcuse-Kubitza

schemas/util.sql: added raise(type text, msg text)

12514 02/27/2014 07:59 AM Aaron Marcuse-Kubitza

schemas/util.sql: eval2val(): made it STABLE so that functions that use it can themselves be inlined. (Postgres apparently ignores the STABLE qualifier, without warning, if the function contains any VOLATILE statements.)

12504 02/26/2014 10:50 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_regexp(regclass)

12502 02/26/2014 10:05 PM Aaron Marcuse-Kubitza

schemas/util.sql: drop_relations_like(): use util.schema_regexp()

12501 02/26/2014 10:02 PM Aaron Marcuse-Kubitza

schemas/util.sql: added schema_regexp(schema_anchor)

12498 02/26/2014 11:58 AM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): documented how to write a custom keys() function to match up rows using a subset of the columns (including a sample keys() function template)

12496 02/26/2014 10:42 AM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: diff(text, text): in the %== comparison, it turns out you do need to cast the values to the same base type, even though this is optional when using a custom %==

12495 02/25/2014 11:51 PM Aaron Marcuse-Kubitza

schemas/util.sql: remake_diff_table(): prepend the "view this table in human-readable form" comment instead of appending because it is more important than the "contents generated from" comment previously added

12494 02/25/2014 11:49 PM Aaron Marcuse-Kubitza

schemas/util.sql: added prepend_comment()

12493 02/25/2014 11:39 PM Aaron Marcuse-Kubitza

schemas/util.sql: removed no longer used mk_set_search_path(VARIADIC schemas text[]). use mk_search_path() instead.

12492 02/25/2014 11:36 PM Aaron Marcuse-Kubitza

schemas/util.sql, vegbien.sql: comment about "function option search_path": don't include `mk_set_search_path()` since that is no longer used

12491 02/25/2014 11:35 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): always use the schema of col_type_null (the common base type) as the search_path, since any custom %== operator for it will always be in the same schema as it

12490 02/25/2014 11:28 PM Aaron Marcuse-Kubitza

schemas/util.sql: use_own_schema(): renamed to use_schema() because this can be used for any type-linked schema

12488 02/25/2014 11:19 PM Aaron Marcuse-Kubitza

schemas/util.sql: use_own_schema(): auto-append util to the search_path to enable use of util operators

12487 02/25/2014 11:11 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_set_search_path(): no need to debug_print_return_value() anymore because functions now use set_search_path() (or something that calls it), which debug-prints the statement (`EXECUTE util.mk_set_search_path()` did not)

12486 02/25/2014 11:06 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_search_path(), mk_set_search_path(text...): auto-append util to the search_path to enable use of util operators

12485 02/25/2014 10:49 PM Aaron Marcuse-Kubitza

schemas/util.sql: removed no longer used mk_use_own_schema(). use util.use_own_schema() instead.

12484 02/25/2014 10:48 PM Aaron Marcuse-Kubitza

schemas/util.sql, vegbien.sql: use util.use_own_schema()/util.set_search_path() instead of EXECUTE util.mk_use_own_schema()/util.mk_set_search_path()

12483 02/25/2014 10:42 PM Aaron Marcuse-Kubitza

schemas/util.sql: added use_own_schema()

12482 02/25/2014 10:40 PM Aaron Marcuse-Kubitza

schemas/util.sql: added set_search_path()

12481 02/25/2014 10:36 PM Aaron Marcuse-Kubitza

schemas/util.sql: runnable_sql(): don't output search_path before a SET statement

12480 02/25/2014 10:31 PM Aaron Marcuse-Kubitza

schemas/util.sql: added is_set_stmt()

12479 02/25/2014 09:28 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): use mk_diff_query()'s new cols param to avoid a nested SELECT

12478 02/25/2014 09:17 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_diff_query(): parameterized the customizable parts of the query, to allow them to be replaced with their EXPLAIN expansion (which is what we ultimately want, so that the query does not refer to any internal tables or views)

12477 02/25/2014 09:02 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): use util.mk_diff_query(). this splits the complex query-generation code apart from the query-execution code.

12476 02/25/2014 08:51 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: undid r12472 because the command needed to limit the effects of any `SET LOCAL search_path` to the current function will unfortunately also clear any existing search_path, which may be needed for the eval query to execute

12475 02/25/2014 08:25 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_diff_query()

12474 02/25/2014 08:13 PM Aaron Marcuse-Kubitza

schemas/util.sql: debug_print_sql(): use runnable_sql()

12473 02/25/2014 08:12 PM Aaron Marcuse-Kubitza

schemas/util.sql: added runnable_sql()

12472 02/25/2014 08:07 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: eval2*(): added search_path function option in order to limit the effects of any `SET LOCAL search_path` in the invoked query to the current function. however, plain eval() is not changed because it is often used to execute a `SET LOCAL search_path` in the calling function.

12471 02/25/2014 06:03 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): removed unnecessary casts to the base type in the join condition and the WHERE filter. these had been presumed necessary due to errors, but the errors turned out to be caused by the operator not being in the search_path. note that the casts in the columns list are still needed, as described in the associated comment.

12470 02/25/2014 05:40 PM Aaron Marcuse-Kubitza

schemas/util.sql: materialize_query(): add a comment on the table with the query it was generated from

12469 02/25/2014 05:39 PM Aaron Marcuse-Kubitza

schemas/util.sql: debug_print_sql(): util.mk_set_search_path(): use for_printing := true to comment out LOCAL

12468 02/25/2014 04:11 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_set_search_path(text): include LOCAL commented out, because the user might want to run it with another statement as a single command, in which case it would be useful because they will be in the same transaction (http://www.postgresql.org/docs/9.3/static/sql-set.html#AEN81154)

12467 02/25/2014 04:09 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_set_search_path(): added for_printing option like for mk_set_search_path(text)

12466 02/25/2014 04:04 PM Aaron Marcuse-Kubitza

schemas/util.sql: mk_set_search_path(): support creating a SET search_path statement for display as well, which would exclude LOCAL because it doesn't work as a standalone command (http://www.postgresql.org/docs/9.3/static/sql-set.html#AEN81154)

12465 02/25/2014 02:48 PM Aaron Marcuse-Kubitza

schemas/util.sql: debug_print_sql(): include the search_path in case the query contains search_path-dependent elements (such as operators)

12464 02/25/2014 02:45 PM Aaron Marcuse-Kubitza

schemas/util.sql: util.explain2notice_msg(): add newline before and after to visually separate it from other debug info

12463 02/25/2014 02:30 PM Aaron Marcuse-Kubitza

schemas/util.sql: added mk_set_search_path() (which uses the current search_path)

12462 02/25/2014 02:08 PM Aaron Marcuse-Kubitza

schemas/util.sql: diff(text, text): in the outputted FULL JOIN query, documented that you should refer to the EXPLAIN output for the expansion of %==

12461 02/25/2014 01:54 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: first_word(): ignore leading whitespace: need to use util.ltrim_nl(), as ltrim() only removes spaces

12460 02/25/2014 01:46 PM Aaron Marcuse-Kubitza

bugfix: schemas/util.sql: first_word(): need to ignore leading whitespace. this applies to many of our queries, which have a leading newline.

12459 02/25/2014 01:44 PM Aaron Marcuse-Kubitza

schemas/util.sql: explain(): don't debug-print the EXPLAIN, to avoid cluttering up the debug output

12458 02/25/2014 01:41 PM Aaron Marcuse-Kubitza

schemas/util.sql: eval2set(): make debug-printing optional, for use with internal statements

12457 02/25/2014 01:28 PM Aaron Marcuse-Kubitza

schemas/util.sql: added is_explain()

12456 02/25/2014 01:25 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: diff(text, text): FULL JOIN SELECT statement: don't put a comment at the very beginning, because this prevents it from being autoexplained (this is the query we particularly want EXPLAIN output for)

12455 02/25/2014 01:22 PM Aaron Marcuse-Kubitza

fix: schemas/util.sql: debug_print_sql(): only surround EXPLAIN output with newlines if there is any