From 53fcbaf24d349639cc9841a816742091df945521 Mon Sep 17 00:00:00 2001 From: Selena Deckelmann Date: Thu, 11 Apr 2013 17:39:39 -0700 Subject: [PATCH] bug 855423 Change all RAISE ERROR -> NOTICE in stored procs * Add alembic migration (yay!) * Fix a test that no longer needs to expect an exception * Add OR REPLACE to CREATE FUNCTION --- .../5316d4cfc03a_adding_raw_crashes_a.py | 33 ------------ .../5e14d46c725_bug_855423_change_ra.py | 54 +++++++++++++++++++ .../e5eb3c07f2a_adding_uuid_to_exten.py | 26 --------- alembic.ini => config/alembic.ini-dist | 3 +- .../procs/001_update_reports_clean.sql | 8 +-- .../raw_sql/procs/002_version_sort_digit.sql | 2 +- .../raw_sql/procs/003_major_version_sort.sql | 2 +- .../raw_sql/procs/004_crash_hadu.sql | 4 +- .../procs/add_column_if_not_exists.sql | 9 ++-- .../raw_sql/procs/add_new_product.sql | 5 +- .../raw_sql/procs/add_new_release.sql | 14 +++-- .../raw_sql/procs/add_old_release.sql | 2 +- .../raw_sql/procs/aurora_or_nightly.sql | 2 +- .../postgresql/raw_sql/procs/backfill_adu.sql | 2 +- .../raw_sql/procs/backfill_all_dups.sql | 2 +- .../raw_sql/procs/backfill_build_adu.sql | 2 +- .../raw_sql/procs/backfill_correlations.sql | 2 +- .../procs/backfill_crashes_by_user.sql | 2 +- .../procs/backfill_crashes_by_user_build.sql | 2 +- .../raw_sql/procs/backfill_daily_crashes.sql | 2 +- .../raw_sql/procs/backfill_explosiveness.sql | 2 +- .../raw_sql/procs/backfill_hang_report.sql | 2 +- .../procs/backfill_home_page_graph.sql | 2 +- .../procs/backfill_home_page_graph_build.sql | 2 +- .../raw_sql/procs/backfill_matviews.sql | 5 +- .../raw_sql/procs/backfill_nightly_builds.sql | 2 +- .../raw_sql/procs/backfill_one_day.sql | 4 +- .../raw_sql/procs/backfill_rank_compare.sql | 2 +- .../raw_sql/procs/backfill_reports_clean.sql | 2 +- .../procs/backfill_reports_duplicates.sql | 2 +- .../procs/backfill_signature_counts.sql | 2 +- .../raw_sql/procs/backfill_tcbs.sql | 2 +- .../raw_sql/procs/backfill_tcbs_build.sql | 2 +- .../postgresql/raw_sql/procs/build_date.sql | 2 +- .../raw_sql/procs/build_numeric.sql | 2 +- .../raw_sql/procs/check_partitions.sql | 2 +- .../raw_sql/procs/content_count_state.sql | 2 +- .../procs/create_os_version_string.sql | 2 +- .../procs/create_table_if_not_exists.sql | 2 +- .../raw_sql/procs/create_weekly_partition.sql | 2 +- .../raw_sql/procs/crontabber_nodelete.sql | 2 +- .../raw_sql/procs/crontabber_timestamp.sql | 2 +- .../raw_sql/procs/daily_crash_code.sql | 2 +- .../raw_sql/procs/drop_old_partitions.sql | 5 +- .../raw_sql/procs/edit_featured_versions.sql | 8 +-- .../raw_sql/procs/edit_product_info.sql | 8 +-- .../postgresql/raw_sql/procs/get_cores.sql | 2 +- .../raw_sql/procs/get_product_version_ids.sql | 2 +- .../postgresql/raw_sql/procs/initcap.sql | 2 +- .../raw_sql/procs/is_rapid_beta.sql | 2 +- .../postgresql/raw_sql/procs/last_record.sql | 2 +- .../raw_sql/procs/log_priorityjobs.sql | 2 +- .../raw_sql/procs/major_version.sql | 2 +- .../raw_sql/procs/nonzero_string.sql | 4 +- .../raw_sql/procs/old_version_sort.sql | 2 +- .../postgresql/raw_sql/procs/pacific2ts.sql | 2 +- .../raw_sql/procs/pg_stat_statements.sql | 2 +- .../procs/pg_stat_statements_reset.sql | 2 +- .../raw_sql/procs/plugin_count_state.sql | 2 +- .../procs/product_version_sort_number.sql | 2 +- .../raw_sql/procs/reports_clean_done.sql | 2 +- .../procs/reports_clean_weekly_partition.sql | 2 +- .../raw_sql/procs/same_time_fuzzy.sql | 2 +- .../raw_sql/procs/socorro_db_data_refresh.sql | 2 +- .../postgresql/raw_sql/procs/sunset_date.sql | 2 +- .../raw_sql/procs/to_major_version.sql | 2 +- .../procs/transform_rules_insert_order.sql | 2 +- .../procs/transform_rules_update_order.sql | 2 +- .../raw_sql/procs/try_lock_table.sql | 2 +- .../postgresql/raw_sql/procs/tstz_between.sql | 2 +- .../postgresql/raw_sql/procs/update_adu.sql | 13 +++-- .../raw_sql/procs/update_build_adu.sql | 5 +- .../raw_sql/procs/update_correlations.sql | 5 +- .../raw_sql/procs/update_crashes_by_user.sql | 8 +-- .../procs/update_crashes_by_user_build.sql | 8 +-- .../raw_sql/procs/update_daily_crashes.sql | 8 +-- .../raw_sql/procs/update_explosiveness.sql | 8 +-- .../raw_sql/procs/update_final_betas.sql | 2 +- .../raw_sql/procs/update_hang_report.sql | 8 +-- .../raw_sql/procs/update_home_page_graph.sql | 8 +-- .../procs/update_home_page_graph_build.sql | 8 +-- .../procs/update_lookup_new_reports.sql | 2 +- .../raw_sql/procs/update_nightly_builds.sql | 8 +-- .../raw_sql/procs/update_os_versions.sql | 5 +- .../procs/update_os_versions_new_reports.sql | 2 +- .../raw_sql/procs/update_product_versions.sql | 2 +- .../raw_sql/procs/update_rank_compare.sql | 8 +-- .../procs/update_reports_clean_cron.sql | 2 +- .../procs/update_reports_duplicates.sql | 2 +- .../raw_sql/procs/update_signatures.sql | 5 +- .../procs/update_socorro_db_version.sql | 2 +- .../postgresql/raw_sql/procs/update_tcbs.sql | 5 +- .../raw_sql/procs/update_tcbs_build.sql | 5 +- .../postgresql/raw_sql/procs/url2domain.sql | 2 +- .../postgresql/raw_sql/procs/utc_day_is.sql | 2 +- .../postgresql/raw_sql/procs/utc_day_near.sql | 2 +- .../raw_sql/procs/validate_lookup.sql | 5 +- .../raw_sql/procs/version_matches_channel.sql | 2 +- .../postgresql/raw_sql/procs/version_sort.sql | 2 +- .../raw_sql/procs/version_sort_trigger.sql | 2 +- .../version_sort_update_trigger_after.sql | 2 +- .../version_sort_update_trigger_before.sql | 2 +- .../raw_sql/procs/version_string.sql | 4 +- .../raw_sql/procs/watch_report_processing.sql | 2 +- .../raw_sql/procs/week_begins_partition.sql | 2 +- .../procs/week_begins_partition_string.sql | 2 +- .../raw_sql/procs/week_begins_utc.sql | 2 +- .../raw_sql/procs/week_ends_partition.sql | 2 +- .../procs/week_ends_partition_string.sql | 2 +- .../procs/weekly_report_partitions.sql | 2 +- socorro/unittest/lib/test_buildutil.py | 7 +-- 111 files changed, 252 insertions(+), 223 deletions(-) delete mode 100644 alembic/versions/5316d4cfc03a_adding_raw_crashes_a.py create mode 100644 alembic/versions/5e14d46c725_bug_855423_change_ra.py delete mode 100644 alembic/versions/e5eb3c07f2a_adding_uuid_to_exten.py rename alembic.ini => config/alembic.ini-dist (92%) diff --git a/alembic/versions/5316d4cfc03a_adding_raw_crashes_a.py b/alembic/versions/5316d4cfc03a_adding_raw_crashes_a.py deleted file mode 100644 index 111076a9b1..0000000000 --- a/alembic/versions/5316d4cfc03a_adding_raw_crashes_a.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Adding raw_crashes and raw_adu.received_at - -Revision ID: 5316d4cfc03a -Revises: None -Create Date: 2013-03-26 11:30:19.464380 - -""" - -# revision identifiers, used by Alembic. -revision = '5316d4cfc03a' -down_revision = None - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from socorro.external.postgresql.models import JSON - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.create_table(u'raw_crashes', - sa.Column(u'uuid', postgresql.UUID(), nullable=False, index=True, unique=True), - sa.Column(u'raw_crash', JSON(), nullable=False), - sa.Column(u'date_processed', postgresql.TIMESTAMP(timezone=True), nullable=True) - ) - op.add_column(u'raw_adu', sa.Column(u'received_at', postgresql.TIMESTAMP(timezone=True), server_default='NOW()', nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column(u'raw_adu', u'received_at') - op.drop_table(u'raw_crashes') - ### end Alembic commands ### diff --git a/alembic/versions/5e14d46c725_bug_855423_change_ra.py b/alembic/versions/5e14d46c725_bug_855423_change_ra.py new file mode 100644 index 0000000000..d22ee73794 --- /dev/null +++ b/alembic/versions/5e14d46c725_bug_855423_change_ra.py @@ -0,0 +1,54 @@ +"""bug 855423 change RAISE EXCEPTION to RAISE NOTICE + +Revision ID: 5e14d46c725 +Revises: e5eb3c07f2a +Create Date: 2013-04-11 17:35:34.174009 + +""" + +# revision identifiers, used by Alembic. +revision = '5e14d46c725' +down_revision = None + +from alembic import op +import os + +def upgrade(): + # Load up all the new procedures + app_path=os.getcwd() + procs = [ + '001_update_reports_clean.sql', + 'add_column_if_not_exists.sql', + 'add_new_product.sql', + 'add_new_release.sql', + 'backfill_matviews.sql', + 'crontabber_nodelete.sql', + 'drop_old_partitions.sql', + 'edit_featured_versions.sql', + 'edit_product_info.sql', + 'update_adu.sql', + 'update_build_adu.sql', + 'update_correlations.sql', + 'update_crashes_by_user_build.sql', + 'update_crashes_by_user.sql', + 'update_daily_crashes.sql', + 'update_explosiveness.sql', + 'update_hang_report.sql', + 'update_home_page_graph_build.sql', + 'update_home_page_graph.sql', + 'update_nightly_builds.sql', + 'update_os_versions.sql', + 'update_rank_compare.sql', + 'update_signatures.sql', + 'update_tcbs_build.sql', + 'update_tcbs.sql', + 'validate_lookup.sql' + ] + for myfile in [app_path + '/socorro/external/postgresql/raw_sql/procs/' + line for line in procs]: + proc = open(myfile, 'r').read() + op.execute(proc) + +def downgrade(): + # Tricky. Need to checkout previous revision in repo + # to do this, so leaving for now. + return True diff --git a/alembic/versions/e5eb3c07f2a_adding_uuid_to_exten.py b/alembic/versions/e5eb3c07f2a_adding_uuid_to_exten.py deleted file mode 100644 index d74aadeb51..0000000000 --- a/alembic/versions/e5eb3c07f2a_adding_uuid_to_exten.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Adding uuid to extensions - -Revision ID: e5eb3c07f2a -Revises: 5316d4cfc03a -Create Date: 2013-03-26 14:24:56.425147 - -""" - -# revision identifiers, used by Alembic. -revision = 'e5eb3c07f2a' -down_revision = '5316d4cfc03a' - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column(u'extensions', sa.Column(u'uuid', postgresql.UUID(), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column(u'extensions', u'uuid') - ### end Alembic commands ### diff --git a/alembic.ini b/config/alembic.ini-dist similarity index 92% rename from alembic.ini rename to config/alembic.ini-dist index 002093779d..e69007a72f 100644 --- a/alembic.ini +++ b/config/alembic.ini-dist @@ -11,8 +11,7 @@ file_template = %%(rev)s_%%(slug)s # the 'revision' command, regardless of autogenerate # revision_environment = false -sqlalchemy.url = postgresql://selena:death@localhost/breakpad - +sqlalchemy.url = postgresql://breakpad_rw@localhost/breakpad # Logging configuration [loggers] diff --git a/socorro/external/postgresql/raw_sql/procs/001_update_reports_clean.sql b/socorro/external/postgresql/raw_sql/procs/001_update_reports_clean.sql index a2ad0d5c19..49925ff2e8 100644 --- a/socorro/external/postgresql/raw_sql/procs/001_update_reports_clean.sql +++ b/socorro/external/postgresql/raw_sql/procs/001_update_reports_clean.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_reports_clean(fromtime timestamp with time zone, fortime interval DEFAULT '01:00:00'::interval, checkdata boolean DEFAULT true, analyze_it boolean DEFAULT true) RETURNS boolean +CREATE OR REPLACE FUNCTION update_reports_clean(fromtime timestamp with time zone, fortime interval DEFAULT '01:00:00'::interval, checkdata boolean DEFAULT true, analyze_it boolean DEFAULT true) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $_$ @@ -31,7 +31,8 @@ END IF; -- prevent calling for a period of more than one day IF fortime > INTERVAL '1 day' THEN - RAISE EXCEPTION 'you may not execute this function on more than one day of data'; + RAISE NOTICE 'you may not execute this function on more than one day of data'; + RETURN FALSE; END IF; -- create a temporary table from the hour of reports you want to @@ -76,7 +77,8 @@ PERFORM 1 FROM new_reports LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'no report data found for period %',fromtime; + RAISE NOTICE 'no report data found for period %',fromtime; + RETURN FALSE; ELSE DROP TABLE new_reports; RETURN TRUE; diff --git a/socorro/external/postgresql/raw_sql/procs/002_version_sort_digit.sql b/socorro/external/postgresql/raw_sql/procs/002_version_sort_digit.sql index 2f148235ba..0a3e15d9a0 100644 --- a/socorro/external/postgresql/raw_sql/procs/002_version_sort_digit.sql +++ b/socorro/external/postgresql/raw_sql/procs/002_version_sort_digit.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_sort_digit(digit text) RETURNS text +CREATE OR REPLACE FUNCTION version_sort_digit(digit text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- converts an individual part of a version number diff --git a/socorro/external/postgresql/raw_sql/procs/003_major_version_sort.sql b/socorro/external/postgresql/raw_sql/procs/003_major_version_sort.sql index 7de0d09479..1e4d147694 100644 --- a/socorro/external/postgresql/raw_sql/procs/003_major_version_sort.sql +++ b/socorro/external/postgresql/raw_sql/procs/003_major_version_sort.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION major_version_sort(version text) RETURNS text +CREATE OR REPLACE FUNCTION major_version_sort(version text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- converts a major_version string into a padded, diff --git a/socorro/external/postgresql/raw_sql/procs/004_crash_hadu.sql b/socorro/external/postgresql/raw_sql/procs/004_crash_hadu.sql index 40e234991f..6f385721e2 100644 --- a/socorro/external/postgresql/raw_sql/procs/004_crash_hadu.sql +++ b/socorro/external/postgresql/raw_sql/procs/004_crash_hadu.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION crash_hadu(crashes bigint, adu bigint, throttle numeric DEFAULT 1.0) RETURNS numeric +CREATE OR REPLACE FUNCTION crash_hadu(crashes bigint, adu bigint, throttle numeric DEFAULT 1.0) RETURNS numeric LANGUAGE sql AS $_$ SELECT CASE WHEN $2 = 0 THEN 0::numeric @@ -7,7 +7,7 @@ ELSE END; $_$; -CREATE FUNCTION crash_hadu(crashes bigint, adu numeric, throttle numeric DEFAULT 1.0) RETURNS numeric +CREATE OR REPLACE FUNCTION crash_hadu(crashes bigint, adu numeric, throttle numeric DEFAULT 1.0) RETURNS numeric LANGUAGE sql AS $_$ SELECT CASE WHEN $2 = 0 THEN 0::numeric diff --git a/socorro/external/postgresql/raw_sql/procs/add_column_if_not_exists.sql b/socorro/external/postgresql/raw_sql/procs/add_column_if_not_exists.sql index 72c3c8499d..b6ff331e0f 100644 --- a/socorro/external/postgresql/raw_sql/procs/add_column_if_not_exists.sql +++ b/socorro/external/postgresql/raw_sql/procs/add_column_if_not_exists.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION add_column_if_not_exists(tablename text, columnname text, datatype text, nonnull boolean DEFAULT false, defaultval text DEFAULT ''::text, constrainttext text DEFAULT ''::text) RETURNS boolean +CREATE OR REPLACE FUNCTION add_column_if_not_exists(tablename text, columnname text, datatype text, nonnull boolean DEFAULT false, defaultval text DEFAULT ''::text, constrainttext text DEFAULT ''::text) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN @@ -11,7 +11,8 @@ BEGIN -- validate input IF nonnull AND ( defaultval = '' ) THEN - RAISE EXCEPTION 'for NOT NULL columns, you must add a default'; + RAISE NOTICE 'for NOT NULL columns, you must add a default'; + RETURN FALSE; END IF; IF defaultval <> '' THEN @@ -19,11 +20,11 @@ IF defaultval <> '' THEN END IF; -- check if the column already exists. -PERFORM 1 +PERFORM 1 FROM information_schema.columns WHERE table_name = tablename AND column_name = columnname; - + IF FOUND THEN RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/add_new_product.sql b/socorro/external/postgresql/raw_sql/procs/add_new_product.sql index adf777bf8f..d39ddafd62 100644 --- a/socorro/external/postgresql/raw_sql/procs/add_new_product.sql +++ b/socorro/external/postgresql/raw_sql/procs/add_new_product.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION add_new_product(prodname text, initversion major_version, prodid text DEFAULT NULL::text, ftpname text DEFAULT NULL::text, release_throttle numeric DEFAULT 1.0, rapid_beta_version numeric DEFAULT 999.0) RETURNS boolean +CREATE OR REPLACE FUNCTION add_new_product(prodname text, initversion major_version, prodid text DEFAULT NULL::text, ftpname text DEFAULT NULL::text, release_throttle numeric DEFAULT 1.0, rapid_beta_version numeric DEFAULT 999.0) RETURNS boolean LANGUAGE plpgsql AS $$ declare current_sort int; @@ -6,7 +6,8 @@ declare current_sort int; begin IF prodname IS NULL OR initversion IS NULL THEN - RAISE EXCEPTION 'a product name and initial version are required'; + RAISE NOTICE 'a product name and initial version are required'; + RETURN FALSE; END IF; -- check if product already exists diff --git a/socorro/external/postgresql/raw_sql/procs/add_new_release.sql b/socorro/external/postgresql/raw_sql/procs/add_new_release.sql index 16e7aaf64e..4e297f5325 100644 --- a/socorro/external/postgresql/raw_sql/procs/add_new_release.sql +++ b/socorro/external/postgresql/raw_sql/procs/add_new_release.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION add_new_release(product citext, version citext, release_channel citext, build_id numeric, platform citext, beta_number integer DEFAULT NULL::integer, repository text DEFAULT 'release'::text, update_products boolean DEFAULT false, ignore_duplicates boolean DEFAULT false) RETURNS boolean +CREATE OR REPLACE FUNCTION add_new_release(product citext, version citext, release_channel citext, build_id numeric, platform citext, beta_number integer DEFAULT NULL::integer, repository text DEFAULT 'release'::text, update_products boolean DEFAULT false, ignore_duplicates boolean DEFAULT false) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE rname citext; @@ -11,7 +11,8 @@ BEGIN IF NOT ( nonzero_string(product) AND nonzero_string(version) AND nonzero_string(release_channel) and nonzero_string(platform) AND build_id IS NOT NULL ) THEN - RAISE EXCEPTION 'product, version, release_channel, platform and build ID are all required'; + RAISE NOTICE 'product, version, release_channel, platform and build ID are all required'; + RETURN FALSE; END IF; -- product @@ -23,7 +24,8 @@ IF rname IS NULL THEN SELECT release_name INTO rname FROM products WHERE product_name = product; IF rname IS NULL THEN - RAISE EXCEPTION 'You must supply a valid product or product release name'; + RAISE NOTICE 'You must supply a valid product or product release name'; + RETURN FALSE; END IF; END IF; @@ -32,7 +34,8 @@ PERFORM validate_lookup('release_channels','release_channel',release_channel,'re --validate build IF NOT ( build_date(build_id) BETWEEN '2005-01-01' AND (current_date + INTERVAL '1 month') ) THEN - RAISE EXCEPTION 'invalid buildid'; + RAISE NOTICE 'invalid buildid'; + RETURN FALSE; END IF; --add row @@ -57,7 +60,8 @@ EXCEPTION IF ignore_duplicates THEN RETURN FALSE; ELSE - RAISE EXCEPTION 'the release you have entered is already present in he database'; + RAISE NOTICE 'the release you have entered is already present in he database'; + RETURN FALSE; END IF; END;$$; diff --git a/socorro/external/postgresql/raw_sql/procs/add_old_release.sql b/socorro/external/postgresql/raw_sql/procs/add_old_release.sql index 32c021e03c..568948be9b 100644 --- a/socorro/external/postgresql/raw_sql/procs/add_old_release.sql +++ b/socorro/external/postgresql/raw_sql/procs/add_old_release.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION add_old_release(product_name text, new_version text, release_type release_enum DEFAULT 'major'::release_enum, release_date date DEFAULT ('now'::text)::date, is_featured boolean DEFAULT false) RETURNS boolean +CREATE OR REPLACE FUNCTION add_old_release(product_name text, new_version text, release_type release_enum DEFAULT 'major'::release_enum, release_date date DEFAULT ('now'::text)::date, is_featured boolean DEFAULT false) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE last_date DATE; diff --git a/socorro/external/postgresql/raw_sql/procs/aurora_or_nightly.sql b/socorro/external/postgresql/raw_sql/procs/aurora_or_nightly.sql index 114aad66fd..177526d7b8 100644 --- a/socorro/external/postgresql/raw_sql/procs/aurora_or_nightly.sql +++ b/socorro/external/postgresql/raw_sql/procs/aurora_or_nightly.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION aurora_or_nightly(version text) RETURNS text +CREATE OR REPLACE FUNCTION aurora_or_nightly(version text) RETURNS text LANGUAGE sql IMMUTABLE STRICT AS $_$ -- figures out "aurora" or "nightly" from a version string diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_adu.sql b/socorro/external/postgresql/raw_sql/procs/backfill_adu.sql index c7eab30451..b83d50e5ff 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_adu.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_adu.sql @@ -1,5 +1,5 @@ -CREATE FUNCTION backfill_adu(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_adu(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_all_dups.sql b/socorro/external/postgresql/raw_sql/procs/backfill_all_dups.sql index 6fe1983254..f41127fcf4 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_all_dups.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_all_dups.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_all_dups(start_date timestamp without time zone, end_date timestamp without time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_all_dups(start_date timestamp without time zone, end_date timestamp without time zone) RETURNS boolean LANGUAGE plpgsql AS $$ declare this_time timestamp; diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_build_adu.sql b/socorro/external/postgresql/raw_sql/procs/backfill_build_adu.sql index fccb3c114e..12a7ebcb63 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_build_adu.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_build_adu.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_build_adu(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_build_adu(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_correlations.sql b/socorro/external/postgresql/raw_sql/procs/backfill_correlations.sql index f622360616..f114961757 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_correlations.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_correlations.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_correlations(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_correlations(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user.sql b/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user.sql index 69f88d7b8d..10f2e593e4 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_crashes_by_user(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_crashes_by_user(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user_build.sql b/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user_build.sql index 5505d2b0f9..736dbc0774 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_crashes_by_user_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_crashes_by_user_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_crashes_by_user_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_daily_crashes.sql b/socorro/external/postgresql/raw_sql/procs/backfill_daily_crashes.sql index a6e4936b04..d06759642d 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_daily_crashes.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_daily_crashes.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_daily_crashes(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_daily_crashes(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_explosiveness.sql b/socorro/external/postgresql/raw_sql/procs/backfill_explosiveness.sql index 9ea8080380..09ac68b885 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_explosiveness.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_explosiveness.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_explosiveness(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_explosiveness(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_hang_report.sql b/socorro/external/postgresql/raw_sql/procs/backfill_hang_report.sql index 8a5a7e1fc6..551db69d98 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_hang_report.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_hang_report.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_hang_report(backfilldate date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_hang_report(backfilldate date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph.sql b/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph.sql index d87cf7f868..d28b5c0fe6 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_home_page_graph(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_home_page_graph(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph_build.sql b/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph_build.sql index e92662b3eb..513dcd9499 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_home_page_graph_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_home_page_graph_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_home_page_graph_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_matviews.sql b/socorro/external/postgresql/raw_sql/procs/backfill_matviews.sql index 9ac7efe09d..4f7b98aa2e 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_matviews.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_matviews.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_matviews(firstday date, lastday date DEFAULT NULL::date, reportsclean boolean DEFAULT true) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_matviews(firstday date, lastday date DEFAULT NULL::date, reportsclean boolean DEFAULT true) RETURNS boolean LANGUAGE plpgsql SET "TimeZone" TO 'UTC' AS $$ @@ -24,7 +24,8 @@ first_rc := firstday AT TIME ZONE 'UTC'; -- check parameters IF firstday > current_date OR lastday > current_date THEN - RAISE EXCEPTION 'date parameter error: cannot backfill into the future'; + RAISE NOTICE 'date parameter error: cannot backfill into the future'; + RETURN FALSE; END IF; -- set optional end date diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_nightly_builds.sql b/socorro/external/postgresql/raw_sql/procs/backfill_nightly_builds.sql index b5aa245759..c6c8fa3068 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_nightly_builds.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_nightly_builds.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_nightly_builds(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_nightly_builds(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_one_day.sql b/socorro/external/postgresql/raw_sql/procs/backfill_one_day.sql index 4156595dac..c090fe50c1 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_one_day.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_one_day.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_one_day() RETURNS text +CREATE OR REPLACE FUNCTION backfill_one_day() RETURNS text LANGUAGE plpgsql AS $$ declare datematch text; @@ -42,7 +42,7 @@ begin END; $$; -CREATE FUNCTION backfill_one_day(bkdate date) RETURNS text +CREATE OR REPLACE FUNCTION backfill_one_day(bkdate date) RETURNS text LANGUAGE plpgsql AS $$ declare datematch text; diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_rank_compare.sql b/socorro/external/postgresql/raw_sql/procs/backfill_rank_compare.sql index 4248a34da4..67de68fef9 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_rank_compare.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_rank_compare.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_rank_compare(updateday date DEFAULT NULL::date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_rank_compare(updateday date DEFAULT NULL::date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_reports_clean.sql b/socorro/external/postgresql/raw_sql/procs/backfill_reports_clean.sql index f62e0bf81e..e7430b38f8 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_reports_clean.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_reports_clean.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_reports_clean(begin_time timestamp with time zone, end_time timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_reports_clean(begin_time timestamp with time zone, end_time timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS boolean LANGUAGE plpgsql AS $$ -- administrative utility for backfilling reports_clean to the selected date diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_reports_duplicates.sql b/socorro/external/postgresql/raw_sql/procs/backfill_reports_duplicates.sql index 06804f362d..421b00e216 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_reports_duplicates.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_reports_duplicates.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_reports_duplicates(start_time timestamp without time zone, end_time timestamp without time zone) RETURNS integer +CREATE OR REPLACE FUNCTION backfill_reports_duplicates(start_time timestamp without time zone, end_time timestamp without time zone) RETURNS integer LANGUAGE plpgsql AS $$ declare new_dups INT; diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_signature_counts.sql b/socorro/external/postgresql/raw_sql/procs/backfill_signature_counts.sql index cb6b951e98..401141e56e 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_signature_counts.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_signature_counts.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_signature_counts(begindate date, enddate date) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_signature_counts(begindate date, enddate date) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE thisdate DATE := begindate; diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_tcbs.sql b/socorro/external/postgresql/raw_sql/procs/backfill_tcbs.sql index d21436ae58..a25b60d928 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_tcbs.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_tcbs.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_tcbs(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_tcbs(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/backfill_tcbs_build.sql b/socorro/external/postgresql/raw_sql/procs/backfill_tcbs_build.sql index 3bb2384362..aaa13e68aa 100644 --- a/socorro/external/postgresql/raw_sql/procs/backfill_tcbs_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/backfill_tcbs_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION backfill_tcbs_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION backfill_tcbs_build(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/build_date.sql b/socorro/external/postgresql/raw_sql/procs/build_date.sql index 199596b752..e740bd587f 100644 --- a/socorro/external/postgresql/raw_sql/procs/build_date.sql +++ b/socorro/external/postgresql/raw_sql/procs/build_date.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION build_date(build_id numeric) RETURNS date +CREATE OR REPLACE FUNCTION build_date(build_id numeric) RETURNS date LANGUAGE sql IMMUTABLE AS $_$ -- converts build number to a date diff --git a/socorro/external/postgresql/raw_sql/procs/build_numeric.sql b/socorro/external/postgresql/raw_sql/procs/build_numeric.sql index 56d92c4467..be743943fe 100644 --- a/socorro/external/postgresql/raw_sql/procs/build_numeric.sql +++ b/socorro/external/postgresql/raw_sql/procs/build_numeric.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION build_numeric(character varying) RETURNS numeric +CREATE OR REPLACE FUNCTION build_numeric(character varying) RETURNS numeric LANGUAGE sql STRICT AS $_$ -- safely converts a build number to a numeric type diff --git a/socorro/external/postgresql/raw_sql/procs/check_partitions.sql b/socorro/external/postgresql/raw_sql/procs/check_partitions.sql index a817969e16..7cfc5418b9 100644 --- a/socorro/external/postgresql/raw_sql/procs/check_partitions.sql +++ b/socorro/external/postgresql/raw_sql/procs/check_partitions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION check_partitions(tables text[], numpartitions integer, OUT result integer, OUT data text) RETURNS record +CREATE OR REPLACE FUNCTION check_partitions(tables text[], numpartitions integer, OUT result integer, OUT data text) RETURNS record LANGUAGE plpgsql AS $$ DECLARE cur_partition TEXT; diff --git a/socorro/external/postgresql/raw_sql/procs/content_count_state.sql b/socorro/external/postgresql/raw_sql/procs/content_count_state.sql index 7513d7bb82..87c31bb708 100644 --- a/socorro/external/postgresql/raw_sql/procs/content_count_state.sql +++ b/socorro/external/postgresql/raw_sql/procs/content_count_state.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION content_count_state(running_count integer, process_type citext, crash_count integer) RETURNS integer +CREATE OR REPLACE FUNCTION content_count_state(running_count integer, process_type citext, crash_count integer) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ -- allows us to do a content crash count diff --git a/socorro/external/postgresql/raw_sql/procs/create_os_version_string.sql b/socorro/external/postgresql/raw_sql/procs/create_os_version_string.sql index f6206d7a39..129b7b41f5 100644 --- a/socorro/external/postgresql/raw_sql/procs/create_os_version_string.sql +++ b/socorro/external/postgresql/raw_sql/procs/create_os_version_string.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION create_os_version_string(osname citext, major integer, minor integer) RETURNS citext +CREATE OR REPLACE FUNCTION create_os_version_string(osname citext, major integer, minor integer) RETURNS citext LANGUAGE plpgsql STABLE STRICT AS $$ DECLARE winversion CITEXT; diff --git a/socorro/external/postgresql/raw_sql/procs/create_table_if_not_exists.sql b/socorro/external/postgresql/raw_sql/procs/create_table_if_not_exists.sql index 30308ad6d4..26be3ac534 100644 --- a/socorro/external/postgresql/raw_sql/procs/create_table_if_not_exists.sql +++ b/socorro/external/postgresql/raw_sql/procs/create_table_if_not_exists.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION create_table_if_not_exists(tablename text, declaration text, tableowner text DEFAULT ''::text, indexes text[] DEFAULT '{}'::text[]) RETURNS boolean +CREATE OR REPLACE FUNCTION create_table_if_not_exists(tablename text, declaration text, tableowner text DEFAULT ''::text, indexes text[] DEFAULT '{}'::text[]) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE dex INT := 1; diff --git a/socorro/external/postgresql/raw_sql/procs/create_weekly_partition.sql b/socorro/external/postgresql/raw_sql/procs/create_weekly_partition.sql index 896288a4c7..6f4376fa98 100644 --- a/socorro/external/postgresql/raw_sql/procs/create_weekly_partition.sql +++ b/socorro/external/postgresql/raw_sql/procs/create_weekly_partition.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION create_weekly_partition(tablename citext, theweek date, partcol text DEFAULT 'date_processed'::text, tableowner text DEFAULT ''::text, uniques text[] DEFAULT '{}'::text[], indexes text[] DEFAULT '{}'::text[], fkeys text[] DEFAULT '{}'::text[], is_utc boolean DEFAULT false, timetype text DEFAULT 'TIMESTAMP'::text) RETURNS boolean +CREATE OR REPLACE FUNCTION create_weekly_partition(tablename citext, theweek date, partcol text DEFAULT 'date_processed'::text, tableowner text DEFAULT ''::text, uniques text[] DEFAULT '{}'::text[], indexes text[] DEFAULT '{}'::text[], fkeys text[] DEFAULT '{}'::text[], is_utc boolean DEFAULT false, timetype text DEFAULT 'TIMESTAMP'::text) RETURNS boolean LANGUAGE plpgsql AS $_$ DECLARE dex INT := 1; diff --git a/socorro/external/postgresql/raw_sql/procs/crontabber_nodelete.sql b/socorro/external/postgresql/raw_sql/procs/crontabber_nodelete.sql index fd4d45c09e..ccbce93903 100644 --- a/socorro/external/postgresql/raw_sql/procs/crontabber_nodelete.sql +++ b/socorro/external/postgresql/raw_sql/procs/crontabber_nodelete.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION crontabber_nodelete() RETURNS trigger +CREATE OR REPLACE FUNCTION crontabber_nodelete() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/crontabber_timestamp.sql b/socorro/external/postgresql/raw_sql/procs/crontabber_timestamp.sql index d43090512e..c275ee0184 100644 --- a/socorro/external/postgresql/raw_sql/procs/crontabber_timestamp.sql +++ b/socorro/external/postgresql/raw_sql/procs/crontabber_timestamp.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION crontabber_timestamp() RETURNS trigger +CREATE OR REPLACE FUNCTION crontabber_timestamp() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/daily_crash_code.sql b/socorro/external/postgresql/raw_sql/procs/daily_crash_code.sql index afa6febec1..6dadba0718 100644 --- a/socorro/external/postgresql/raw_sql/procs/daily_crash_code.sql +++ b/socorro/external/postgresql/raw_sql/procs/daily_crash_code.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION daily_crash_code(process_type text, hangid text) RETURNS character +CREATE OR REPLACE FUNCTION daily_crash_code(process_type text, hangid text) RETURNS character LANGUAGE sql IMMUTABLE AS $_$ SELECT CASE diff --git a/socorro/external/postgresql/raw_sql/procs/drop_old_partitions.sql b/socorro/external/postgresql/raw_sql/procs/drop_old_partitions.sql index 814fce42d2..09995ba05b 100644 --- a/socorro/external/postgresql/raw_sql/procs/drop_old_partitions.sql +++ b/socorro/external/postgresql/raw_sql/procs/drop_old_partitions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION drop_old_partitions(mastername text, cutoffdate date) RETURNS boolean +CREATE OR REPLACE FUNCTION drop_old_partitions(mastername text, cutoffdate date) RETURNS boolean LANGUAGE plpgsql AS $_X$ DECLARE tabname TEXT; @@ -16,7 +16,8 @@ IF try_lock_table(mastername,'ACCESS EXCLUSIVE') THEN END LOOP; ELSE - RAISE EXCEPTION 'Unable to lock table plugin_reports; try again later'; + RAISE NOTICE 'Unable to lock table plugin_reports; try again later'; + RETURN FALSE; END IF; RETURN TRUE; END; diff --git a/socorro/external/postgresql/raw_sql/procs/edit_featured_versions.sql b/socorro/external/postgresql/raw_sql/procs/edit_featured_versions.sql index ea74c60d2f..977a94761c 100644 --- a/socorro/external/postgresql/raw_sql/procs/edit_featured_versions.sql +++ b/socorro/external/postgresql/raw_sql/procs/edit_featured_versions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION edit_featured_versions(product citext, VARIADIC featured_versions text[]) RETURNS boolean +CREATE OR REPLACE FUNCTION edit_featured_versions(product citext, VARIADIC featured_versions text[]) RETURNS boolean LANGUAGE plpgsql AS $$ -- this function allows admins to change the featured versions @@ -7,7 +7,8 @@ BEGIN --check required parameters IF NOT ( nonzero_string(product) AND nonzero_string(featured_versions[1]) ) THEN - RAISE EXCEPTION 'a product name and at least one version are required'; + RAISE NOTICE 'a product name and at least one version are required'; + RETURN FALSE; END IF; --check that all versions are not expired @@ -16,7 +17,8 @@ WHERE product_name = product AND version_string = ANY ( featured_versions ) AND sunset_date < current_date; IF FOUND THEN - RAISE EXCEPTION 'one or more of the versions you have selected is already expired'; + RAISE NOTICE 'one or more of the versions you have selected is already expired'; + RETURN FALSE; END IF; --Remove disfeatured versions diff --git a/socorro/external/postgresql/raw_sql/procs/edit_product_info.sql b/socorro/external/postgresql/raw_sql/procs/edit_product_info.sql index 91a54a4262..ccf85fd2bb 100644 --- a/socorro/external/postgresql/raw_sql/procs/edit_product_info.sql +++ b/socorro/external/postgresql/raw_sql/procs/edit_product_info.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION edit_product_info(prod_id integer, prod_name citext, prod_version text, prod_channel text, begin_visibility date, end_visibility date, is_featured boolean, crash_throttle numeric, user_name text DEFAULT ''::text) RETURNS integer +CREATE OR REPLACE FUNCTION edit_product_info(prod_id integer, prod_name citext, prod_version text, prod_channel text, begin_visibility date, end_visibility date, is_featured boolean, crash_throttle numeric, user_name text DEFAULT ''::text) RETURNS integer LANGUAGE plpgsql AS $$ DECLARE which_t text; @@ -28,7 +28,8 @@ IF prod_id IS NULL THEN WHERE product_name = prod_name AND major_version_sort(prod_version) >= major_version_sort(rapid_release_version); IF FOUND AND prod_version NOT LIKE '%a%' THEN - RAISE EXCEPTION 'Product % version % will be automatically updated by the new system. As such, you may not add this product & version manually.',prod_name,prod_version; + RAISE NOTICE 'Product % version % will be automatically updated by the new system. As such, you may not add this product & version manually.',prod_name,prod_version; + RETURN FALSE; ELSE INSERT INTO productdims ( product, version, branch, release ) @@ -52,7 +53,8 @@ ELSE FROM product_info WHERE product_version_id = prod_id; IF NOT FOUND THEN - RAISE EXCEPTION 'No product with that ID was found. Database Error.'; + RAISE NOTICE 'No product with that ID was found. Database Error.'; + RETURN FALSE; END IF; IF which_t = 'new' THEN diff --git a/socorro/external/postgresql/raw_sql/procs/get_cores.sql b/socorro/external/postgresql/raw_sql/procs/get_cores.sql index bda0b6fa03..6378e77f16 100644 --- a/socorro/external/postgresql/raw_sql/procs/get_cores.sql +++ b/socorro/external/postgresql/raw_sql/procs/get_cores.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION get_cores(cpudetails text) RETURNS integer +CREATE OR REPLACE FUNCTION get_cores(cpudetails text) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ SELECT substring($1 from $x$\| (\d+)$$x$)::INT; diff --git a/socorro/external/postgresql/raw_sql/procs/get_product_version_ids.sql b/socorro/external/postgresql/raw_sql/procs/get_product_version_ids.sql index cb1d6388a0..578b4168c3 100644 --- a/socorro/external/postgresql/raw_sql/procs/get_product_version_ids.sql +++ b/socorro/external/postgresql/raw_sql/procs/get_product_version_ids.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION get_product_version_ids(product citext, VARIADIC versions citext[]) RETURNS integer[] +CREATE OR REPLACE FUNCTION get_product_version_ids(product citext, VARIADIC versions citext[]) RETURNS integer[] LANGUAGE sql AS $_$ SELECT array_agg(product_version_id) diff --git a/socorro/external/postgresql/raw_sql/procs/initcap.sql b/socorro/external/postgresql/raw_sql/procs/initcap.sql index 14c996ce45..4198d7c1db 100644 --- a/socorro/external/postgresql/raw_sql/procs/initcap.sql +++ b/socorro/external/postgresql/raw_sql/procs/initcap.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION initcap(text) RETURNS text +CREATE OR REPLACE FUNCTION initcap(text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ SELECT upper(substr($1,1,1)) || substr($1,2); diff --git a/socorro/external/postgresql/raw_sql/procs/is_rapid_beta.sql b/socorro/external/postgresql/raw_sql/procs/is_rapid_beta.sql index d3b05a0e8b..e11ab0ebaf 100644 --- a/socorro/external/postgresql/raw_sql/procs/is_rapid_beta.sql +++ b/socorro/external/postgresql/raw_sql/procs/is_rapid_beta.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION is_rapid_beta(channel citext, repversion text, rbetaversion text) RETURNS boolean +CREATE OR REPLACE FUNCTION is_rapid_beta(channel citext, repversion text, rbetaversion text) RETURNS boolean LANGUAGE sql AS $_$ SELECT $1 = 'beta' AND major_version_sort($2) >= major_version_sort($3); diff --git a/socorro/external/postgresql/raw_sql/procs/last_record.sql b/socorro/external/postgresql/raw_sql/procs/last_record.sql index 74c226596e..49d85ce34e 100644 --- a/socorro/external/postgresql/raw_sql/procs/last_record.sql +++ b/socorro/external/postgresql/raw_sql/procs/last_record.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION last_record(tablename text) RETURNS integer +CREATE OR REPLACE FUNCTION last_record(tablename text) RETURNS integer LANGUAGE plpgsql AS $$ declare curdate timestamp; diff --git a/socorro/external/postgresql/raw_sql/procs/log_priorityjobs.sql b/socorro/external/postgresql/raw_sql/procs/log_priorityjobs.sql index 9489de9918..9c06aeca99 100644 --- a/socorro/external/postgresql/raw_sql/procs/log_priorityjobs.sql +++ b/socorro/external/postgresql/raw_sql/procs/log_priorityjobs.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION log_priorityjobs() RETURNS trigger +CREATE OR REPLACE FUNCTION log_priorityjobs() RETURNS trigger LANGUAGE plpgsql AS $$ declare arewelogging boolean; diff --git a/socorro/external/postgresql/raw_sql/procs/major_version.sql b/socorro/external/postgresql/raw_sql/procs/major_version.sql index 7e0b47ad77..9d4fad5d30 100644 --- a/socorro/external/postgresql/raw_sql/procs/major_version.sql +++ b/socorro/external/postgresql/raw_sql/procs/major_version.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION major_version(version text) RETURNS major_version +CREATE OR REPLACE FUNCTION major_version(version text) RETURNS major_version LANGUAGE sql IMMUTABLE AS $_$ -- turns a version string into a major version diff --git a/socorro/external/postgresql/raw_sql/procs/nonzero_string.sql b/socorro/external/postgresql/raw_sql/procs/nonzero_string.sql index 07a94da455..177657a568 100644 --- a/socorro/external/postgresql/raw_sql/procs/nonzero_string.sql +++ b/socorro/external/postgresql/raw_sql/procs/nonzero_string.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION nonzero_string(citext) RETURNS boolean +CREATE OR REPLACE FUNCTION nonzero_string(citext) RETURNS boolean LANGUAGE sql AS $_$ SELECT btrim($1) <> '' AND $1 IS NOT NULL; @@ -11,7 +11,7 @@ ALTER FUNCTION public.nonzero_string(citext) OWNER TO postgres; -- Name: nonzero_string(text); Type: FUNCTION; Schema: public; Owner: postgres -- -CREATE FUNCTION nonzero_string(text) RETURNS boolean +CREATE OR REPLACE FUNCTION nonzero_string(text) RETURNS boolean LANGUAGE sql AS $_$ SELECT btrim($1) <> '' AND $1 IS NOT NULL; diff --git a/socorro/external/postgresql/raw_sql/procs/old_version_sort.sql b/socorro/external/postgresql/raw_sql/procs/old_version_sort.sql index d4a18031db..d38613945e 100644 --- a/socorro/external/postgresql/raw_sql/procs/old_version_sort.sql +++ b/socorro/external/postgresql/raw_sql/procs/old_version_sort.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION old_version_sort(vers text) RETURNS text +CREATE OR REPLACE FUNCTION old_version_sort(vers text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ SELECT to_char( matched[1]::int, 'FM000' ) diff --git a/socorro/external/postgresql/raw_sql/procs/pacific2ts.sql b/socorro/external/postgresql/raw_sql/procs/pacific2ts.sql index 4645008019..17080d9086 100644 --- a/socorro/external/postgresql/raw_sql/procs/pacific2ts.sql +++ b/socorro/external/postgresql/raw_sql/procs/pacific2ts.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION pacific2ts(timestamp with time zone) RETURNS timestamp without time zone +CREATE OR REPLACE FUNCTION pacific2ts(timestamp with time zone) RETURNS timestamp without time zone LANGUAGE sql STABLE SET "TimeZone" TO 'America/Los_Angeles' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/pg_stat_statements.sql b/socorro/external/postgresql/raw_sql/procs/pg_stat_statements.sql index f5404f8889..cbc67a0d07 100644 --- a/socorro/external/postgresql/raw_sql/procs/pg_stat_statements.sql +++ b/socorro/external/postgresql/raw_sql/procs/pg_stat_statements.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION pg_stat_statements(OUT userid oid, OUT dbid oid, OUT query text, OUT calls bigint, OUT total_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint) RETURNS SETOF record +CREATE OR REPLACE FUNCTION pg_stat_statements(OUT userid oid, OUT dbid oid, OUT query text, OUT calls bigint, OUT total_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint) RETURNS SETOF record LANGUAGE c AS '$libdir/pg_stat_statements', 'pg_stat_statements'; diff --git a/socorro/external/postgresql/raw_sql/procs/pg_stat_statements_reset.sql b/socorro/external/postgresql/raw_sql/procs/pg_stat_statements_reset.sql index 3f30a78dcb..b6def978e7 100644 --- a/socorro/external/postgresql/raw_sql/procs/pg_stat_statements_reset.sql +++ b/socorro/external/postgresql/raw_sql/procs/pg_stat_statements_reset.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION pg_stat_statements_reset() RETURNS void +CREATE OR REPLACE FUNCTION pg_stat_statements_reset() RETURNS void LANGUAGE c AS '$libdir/pg_stat_statements', 'pg_stat_statements_reset'; diff --git a/socorro/external/postgresql/raw_sql/procs/plugin_count_state.sql b/socorro/external/postgresql/raw_sql/procs/plugin_count_state.sql index 806ff048fb..feb59b6c67 100644 --- a/socorro/external/postgresql/raw_sql/procs/plugin_count_state.sql +++ b/socorro/external/postgresql/raw_sql/procs/plugin_count_state.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION plugin_count_state(running_count integer, process_type citext, crash_count integer) RETURNS integer +CREATE OR REPLACE FUNCTION plugin_count_state(running_count integer, process_type citext, crash_count integer) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ -- allows us to do a plugn count horizontally diff --git a/socorro/external/postgresql/raw_sql/procs/product_version_sort_number.sql b/socorro/external/postgresql/raw_sql/procs/product_version_sort_number.sql index e336734090..2d0bc81229 100644 --- a/socorro/external/postgresql/raw_sql/procs/product_version_sort_number.sql +++ b/socorro/external/postgresql/raw_sql/procs/product_version_sort_number.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION product_version_sort_number(sproduct text) RETURNS boolean +CREATE OR REPLACE FUNCTION product_version_sort_number(sproduct text) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/reports_clean_done.sql b/socorro/external/postgresql/raw_sql/procs/reports_clean_done.sql index 6a6803fe4b..9b33753aa4 100644 --- a/socorro/external/postgresql/raw_sql/procs/reports_clean_done.sql +++ b/socorro/external/postgresql/raw_sql/procs/reports_clean_done.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION reports_clean_done(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION reports_clean_done(updateday date, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ -- this function checks that reports_clean has been updated diff --git a/socorro/external/postgresql/raw_sql/procs/reports_clean_weekly_partition.sql b/socorro/external/postgresql/raw_sql/procs/reports_clean_weekly_partition.sql index 4c43b3e6ac..6346fd4dca 100644 --- a/socorro/external/postgresql/raw_sql/procs/reports_clean_weekly_partition.sql +++ b/socorro/external/postgresql/raw_sql/procs/reports_clean_weekly_partition.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION reports_clean_weekly_partition(this_date timestamp with time zone, which_table text) RETURNS text +CREATE OR REPLACE FUNCTION reports_clean_weekly_partition(this_date timestamp with time zone, which_table text) RETURNS text LANGUAGE plpgsql SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/same_time_fuzzy.sql b/socorro/external/postgresql/raw_sql/procs/same_time_fuzzy.sql index 23fde9cd26..9d35b2d595 100644 --- a/socorro/external/postgresql/raw_sql/procs/same_time_fuzzy.sql +++ b/socorro/external/postgresql/raw_sql/procs/same_time_fuzzy.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION same_time_fuzzy(date1 timestamp with time zone, date2 timestamp with time zone, interval_secs1 integer, interval_secs2 integer) RETURNS boolean +CREATE OR REPLACE FUNCTION same_time_fuzzy(date1 timestamp with time zone, date2 timestamp with time zone, interval_secs1 integer, interval_secs2 integer) RETURNS boolean LANGUAGE sql AS $_$ SELECT diff --git a/socorro/external/postgresql/raw_sql/procs/socorro_db_data_refresh.sql b/socorro/external/postgresql/raw_sql/procs/socorro_db_data_refresh.sql index beead185c7..81c6b3c6b9 100644 --- a/socorro/external/postgresql/raw_sql/procs/socorro_db_data_refresh.sql +++ b/socorro/external/postgresql/raw_sql/procs/socorro_db_data_refresh.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION socorro_db_data_refresh(refreshtime timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS timestamp with time zone +CREATE OR REPLACE FUNCTION socorro_db_data_refresh(refreshtime timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS timestamp with time zone LANGUAGE sql AS $_$ UPDATE socorro_db_version SET refreshed_at = COALESCE($1, now()) diff --git a/socorro/external/postgresql/raw_sql/procs/sunset_date.sql b/socorro/external/postgresql/raw_sql/procs/sunset_date.sql index 87dd49e1df..e8b13c05a1 100644 --- a/socorro/external/postgresql/raw_sql/procs/sunset_date.sql +++ b/socorro/external/postgresql/raw_sql/procs/sunset_date.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION sunset_date(build_id numeric, build_type citext) RETURNS date +CREATE OR REPLACE FUNCTION sunset_date(build_id numeric, build_type citext) RETURNS date LANGUAGE sql IMMUTABLE AS $_$ -- sets a sunset date for visibility diff --git a/socorro/external/postgresql/raw_sql/procs/to_major_version.sql b/socorro/external/postgresql/raw_sql/procs/to_major_version.sql index fd1f68a23c..fd28bcc16f 100644 --- a/socorro/external/postgresql/raw_sql/procs/to_major_version.sql +++ b/socorro/external/postgresql/raw_sql/procs/to_major_version.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION to_major_version(version text) RETURNS major_version +CREATE OR REPLACE FUNCTION to_major_version(version text) RETURNS major_version LANGUAGE sql IMMUTABLE AS $_$ -- turns a version string into a major version diff --git a/socorro/external/postgresql/raw_sql/procs/transform_rules_insert_order.sql b/socorro/external/postgresql/raw_sql/procs/transform_rules_insert_order.sql index 21a6c86c9e..5f4311a662 100644 --- a/socorro/external/postgresql/raw_sql/procs/transform_rules_insert_order.sql +++ b/socorro/external/postgresql/raw_sql/procs/transform_rules_insert_order.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION transform_rules_insert_order() RETURNS trigger +CREATE OR REPLACE FUNCTION transform_rules_insert_order() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE order_num INT; diff --git a/socorro/external/postgresql/raw_sql/procs/transform_rules_update_order.sql b/socorro/external/postgresql/raw_sql/procs/transform_rules_update_order.sql index b802977b3e..060adf349f 100644 --- a/socorro/external/postgresql/raw_sql/procs/transform_rules_update_order.sql +++ b/socorro/external/postgresql/raw_sql/procs/transform_rules_update_order.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION transform_rules_update_order() RETURNS trigger +CREATE OR REPLACE FUNCTION transform_rules_update_order() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/try_lock_table.sql b/socorro/external/postgresql/raw_sql/procs/try_lock_table.sql index d87366ae9b..082d40f6f0 100644 --- a/socorro/external/postgresql/raw_sql/procs/try_lock_table.sql +++ b/socorro/external/postgresql/raw_sql/procs/try_lock_table.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION try_lock_table(tabname text, mode text DEFAULT 'EXCLUSIVE'::text, attempts integer DEFAULT 20) RETURNS boolean +CREATE OR REPLACE FUNCTION try_lock_table(tabname text, mode text DEFAULT 'EXCLUSIVE'::text, attempts integer DEFAULT 20) RETURNS boolean LANGUAGE plpgsql AS $$ -- this function tries to lock a table diff --git a/socorro/external/postgresql/raw_sql/procs/tstz_between.sql b/socorro/external/postgresql/raw_sql/procs/tstz_between.sql index f541380fac..2064ccfed1 100644 --- a/socorro/external/postgresql/raw_sql/procs/tstz_between.sql +++ b/socorro/external/postgresql/raw_sql/procs/tstz_between.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION tstz_between(tstz timestamp with time zone, bdate date, fdate date) RETURNS boolean +CREATE OR REPLACE FUNCTION tstz_between(tstz timestamp with time zone, bdate date, fdate date) RETURNS boolean LANGUAGE sql IMMUTABLE AS $_$ SELECT $1 >= ( $2::timestamp AT TIME ZONE 'UTC' ) diff --git a/socorro/external/postgresql/raw_sql/procs/update_adu.sql b/socorro/external/postgresql/raw_sql/procs/update_adu.sql index c7c2533f37..4881cc8ea7 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_adu.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_adu.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_adu(updateday date, checkdata boolean DEFAULT true) RETURNS boolean +CREATE OR REPLACE FUNCTION update_adu(updateday date, checkdata boolean DEFAULT true) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN @@ -12,12 +12,11 @@ PERFORM 1 FROM raw_adu WHERE "date" = updateday LIMIT 1; -IF NOT FOUND THEN - IF checkdata THEN - RAISE EXCEPTION 'raw_adu not updated for %',updateday; - ELSE - RETURN FALSE; - END IF; +IF NOT FOUND and checkdata THEN + RAISE NOTICE 'raw_adu not updated for %', updateday; + RETURN FALSE; +ELSIF NOT FOUND THEN + RETURN FALSE; END IF; -- check if ADU has already been run for the date diff --git a/socorro/external/postgresql/raw_sql/procs/update_build_adu.sql b/socorro/external/postgresql/raw_sql/procs/update_build_adu.sql index f4c7cac2de..a1e9ee3162 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_build_adu.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_build_adu.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_build_adu(updateday date, checkdata boolean DEFAULT true) RETURNS boolean +CREATE OR REPLACE FUNCTION update_build_adu(updateday date, checkdata boolean DEFAULT true) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -24,7 +24,8 @@ WHERE "date" = updateday LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'raw_adu has not been updated for %',updateday; + RAISE NOTICE 'raw_adu has not been updated for %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_correlations.sql b/socorro/external/postgresql/raw_sql/procs/update_correlations.sql index 2bfd6726ee..c6761d8d13 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_correlations.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_correlations.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_correlations(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_correlations(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET work_mem TO '512MB' SET client_min_messages TO 'ERROR' @@ -14,7 +14,8 @@ BEGIN -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user.sql b/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user.sql index 40da61b1b5..912402b594 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_crashes_by_user(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_crashes_by_user(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' SET "TimeZone" TO 'UTC' @@ -22,7 +22,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -35,7 +36,8 @@ WHERE adu_date = updateday LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'product_adu has not been updated for %', updateday; + RAISE NOTICE 'product_adu has not been updated for %', updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user_build.sql b/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user_build.sql index 8d44b5dc59..ac1eb9e299 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_crashes_by_user_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_crashes_by_user_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_crashes_by_user_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' SET "TimeZone" TO 'UTC' @@ -22,7 +22,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -35,7 +36,8 @@ WHERE adu_date = updateday LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'build_adu has not been updated for %', updateday; + RAISE NOTICE 'build_adu has not been updated for %', updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_daily_crashes.sql b/socorro/external/postgresql/raw_sql/procs/update_daily_crashes.sql index 8536068479..fb08a100f1 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_daily_crashes.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_daily_crashes.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_daily_crashes(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_daily_crashes(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN @@ -16,14 +16,16 @@ IF checkdata THEN PERFORM 1 FROM daily_crashes WHERE adu_day = updateday LIMIT 1; IF FOUND THEN - RAISE EXCEPTION 'daily_crashes has already been run for %', updateday; + RAISE NOTICE 'daily_crashes has already been run for %', updateday; + RETURN FALSE; END IF; END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_explosiveness.sql b/socorro/external/postgresql/raw_sql/procs/update_explosiveness.sql index 40d92ef036..05561eba3a 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_explosiveness.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_explosiveness.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_explosiveness(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_explosiveness(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -34,7 +34,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -49,7 +50,8 @@ LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'Either product_adu or tcbs have not been updated to the end of %',updateday; + RAISE NOTICE 'Either product_adu or tcbs have not been updated to the end of %',updateday; + RETURN FALSE; ELSE RAISE NOTICE 'Either product_adu or tcbs has not been updated, skipping.'; RETURN TRUE; diff --git a/socorro/external/postgresql/raw_sql/procs/update_final_betas.sql b/socorro/external/postgresql/raw_sql/procs/update_final_betas.sql index d69d288e25..280b63490d 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_final_betas.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_final_betas.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_final_betas(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION update_final_betas(updateday date) RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/update_hang_report.sql b/socorro/external/postgresql/raw_sql/procs/update_hang_report.sql index 05781c8867..163fe490b9 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_hang_report.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_hang_report.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_hang_report(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_hang_report(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET work_mem TO '512MB' SET maintenance_work_mem TO '512MB' @@ -8,7 +8,8 @@ BEGIN -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -18,7 +19,8 @@ END IF; PERFORM 1 FROM daily_hangs WHERE report_date = updateday LIMIT 1; IF FOUND THEN - RAISE EXCEPTION 'it appears that hang_report has already been run for %. If you are backfilling, use backfill_hang_report instead.',updateday; + RAISE NOTICE 'it appears that hang_report has already been run for %. If you are backfilling, use backfill_hang_report instead.',updateday; + RETURN FALSE; END IF; -- insert data diff --git a/socorro/external/postgresql/raw_sql/procs/update_home_page_graph.sql b/socorro/external/postgresql/raw_sql/procs/update_home_page_graph.sql index 7e38b8bbfe..20345dc457 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_home_page_graph.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_home_page_graph.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_home_page_graph(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_home_page_graph(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' SET "TimeZone" TO 'UTC' @@ -22,7 +22,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -35,7 +36,8 @@ WHERE adu_date = updateday LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'product_adu has not been updated for %', updateday; + RAISE NOTICE 'product_adu has not been updated for %', updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_home_page_graph_build.sql b/socorro/external/postgresql/raw_sql/procs/update_home_page_graph_build.sql index b3b74ec484..de63e67fff 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_home_page_graph_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_home_page_graph_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_home_page_graph_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_home_page_graph_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' SET "TimeZone" TO 'UTC' @@ -19,7 +19,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -32,7 +33,8 @@ WHERE adu_date = updateday LIMIT 1; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'build_adu has not been updated for %', updateday; + RAISE NOTICE 'build_adu has not been updated for %', updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_lookup_new_reports.sql b/socorro/external/postgresql/raw_sql/procs/update_lookup_new_reports.sql index 51eff11e14..131caa2bf4 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_lookup_new_reports.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_lookup_new_reports.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_lookup_new_reports(column_name text) RETURNS boolean +CREATE OR REPLACE FUNCTION update_lookup_new_reports(column_name text) RETURNS boolean LANGUAGE plpgsql AS $$ declare table_name text; diff --git a/socorro/external/postgresql/raw_sql/procs/update_nightly_builds.sql b/socorro/external/postgresql/raw_sql/procs/update_nightly_builds.sql index a04b9cb462..f5aa86ce0f 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_nightly_builds.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_nightly_builds.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_nightly_builds(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_nightly_builds(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -13,14 +13,16 @@ IF checkdata THEN WHERE report_date = updateday LIMIT 1; IF FOUND THEN - RAISE EXCEPTION 'nightly_builds has already been run for %.',updateday; + RAISE NOTICE 'nightly_builds has already been run for %.',updateday; + RETURN FALSE; END IF; END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_os_versions.sql b/socorro/external/postgresql/raw_sql/procs/update_os_versions.sql index 1608abd22b..22e33100d6 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_os_versions.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_os_versions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_os_versions(updateday date) RETURNS boolean +CREATE OR REPLACE FUNCTION update_os_versions(updateday date) RETURNS boolean LANGUAGE plpgsql SET "TimeZone" TO 'UTC' AS $_$ @@ -17,7 +17,8 @@ group by os_name, os_version; PERFORM 1 FROM new_os LIMIT 1; IF NOT FOUND THEN - RAISE EXCEPTION 'No OS data found for date %',updateday; + RAISE NOTICE 'No OS data found for date %',updateday; + RETURN FALSE; END IF; create temporary table os_versions_temp diff --git a/socorro/external/postgresql/raw_sql/procs/update_os_versions_new_reports.sql b/socorro/external/postgresql/raw_sql/procs/update_os_versions_new_reports.sql index f5e170c38d..8333acbb18 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_os_versions_new_reports.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_os_versions_new_reports.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_os_versions_new_reports() RETURNS boolean +CREATE OR REPLACE FUNCTION update_os_versions_new_reports() RETURNS boolean LANGUAGE plpgsql AS $_$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/update_product_versions.sql b/socorro/external/postgresql/raw_sql/procs/update_product_versions.sql index b965192256..88538c660f 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_product_versions.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_product_versions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_product_versions(product_window integer DEFAULT 30) RETURNS boolean +CREATE OR REPLACE FUNCTION update_product_versions(product_window integer DEFAULT 30) RETURNS boolean LANGUAGE plpgsql SET work_mem TO '512MB' SET maintenance_work_mem TO '512MB' diff --git a/socorro/external/postgresql/raw_sql/procs/update_rank_compare.sql b/socorro/external/postgresql/raw_sql/procs/update_rank_compare.sql index 198a213183..ad10af4488 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_rank_compare.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_rank_compare.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_rank_compare(updateday date DEFAULT NULL::date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_rank_compare(updateday date DEFAULT NULL::date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -16,7 +16,8 @@ updateday := COALESCE(updateday, ( CURRENT_DATE -1 )); -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; @@ -24,7 +25,8 @@ END IF; -- obtain a lock on the matview so that we can TRUNCATE IF NOT try_lock_table('rank_compare', 'ACCESS EXCLUSIVE') THEN - RAISE EXCEPTION 'unable to lock the rank_compare table for update.'; + RAISE NOTICE 'unable to lock the rank_compare table for update.'; + RETURN FALSE; END IF; -- create temporary table with totals from reports_clean diff --git a/socorro/external/postgresql/raw_sql/procs/update_reports_clean_cron.sql b/socorro/external/postgresql/raw_sql/procs/update_reports_clean_cron.sql index f7f143b5e1..3335516bd9 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_reports_clean_cron.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_reports_clean_cron.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_reports_clean_cron(crontime timestamp with time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION update_reports_clean_cron(crontime timestamp with time zone) RETURNS boolean LANGUAGE sql AS $_$ SELECT update_reports_clean( date_trunc('hour', $1) - interval '1 hour' ); diff --git a/socorro/external/postgresql/raw_sql/procs/update_reports_duplicates.sql b/socorro/external/postgresql/raw_sql/procs/update_reports_duplicates.sql index 7446eedd4f..51af014381 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_reports_duplicates.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_reports_duplicates.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_reports_duplicates(start_time timestamp with time zone, end_time timestamp with time zone) RETURNS integer +CREATE OR REPLACE FUNCTION update_reports_duplicates(start_time timestamp with time zone, end_time timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $$ declare new_dups INT; diff --git a/socorro/external/postgresql/raw_sql/procs/update_signatures.sql b/socorro/external/postgresql/raw_sql/procs/update_signatures.sql index c6351dd232..94efedf847 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_signatures.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_signatures.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_signatures(updateday date, checkdata boolean DEFAULT true) RETURNS boolean +CREATE OR REPLACE FUNCTION update_signatures(updateday date, checkdata boolean DEFAULT true) RETURNS boolean LANGUAGE plpgsql SET "TimeZone" TO 'UTC' AS $$ @@ -26,7 +26,8 @@ group by signature, product, version, build; PERFORM 1 FROM new_signatures; IF NOT FOUND THEN IF checkdata THEN - RAISE EXCEPTION 'no signature data found in reports for date %',updateday; + RAISE NOTICE 'no signature data found in reports for date %',updateday; + RETURN FALSE; END IF; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_socorro_db_version.sql b/socorro/external/postgresql/raw_sql/procs/update_socorro_db_version.sql index 86461b5a61..2629a8f724 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_socorro_db_version.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_socorro_db_version.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_socorro_db_version(newversion text, backfilldate date DEFAULT NULL::date) RETURNS boolean +CREATE OR REPLACE FUNCTION update_socorro_db_version(newversion text, backfilldate date DEFAULT NULL::date) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE rerun BOOLEAN; diff --git a/socorro/external/postgresql/raw_sql/procs/update_tcbs.sql b/socorro/external/postgresql/raw_sql/procs/update_tcbs.sql index 4a07e45dff..e6dfeedbff 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_tcbs.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_tcbs.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_tcbs(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_tcbs(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -22,7 +22,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RETURN FALSE; END IF; diff --git a/socorro/external/postgresql/raw_sql/procs/update_tcbs_build.sql b/socorro/external/postgresql/raw_sql/procs/update_tcbs_build.sql index 7010f0808e..69689400eb 100644 --- a/socorro/external/postgresql/raw_sql/procs/update_tcbs_build.sql +++ b/socorro/external/postgresql/raw_sql/procs/update_tcbs_build.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION update_tcbs_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean +CREATE OR REPLACE FUNCTION update_tcbs_build(updateday date, checkdata boolean DEFAULT true, check_period interval DEFAULT '01:00:00'::interval) RETURNS boolean LANGUAGE plpgsql SET client_min_messages TO 'ERROR' AS $$ @@ -22,7 +22,8 @@ END IF; -- check if reports_clean is complete IF NOT reports_clean_done(updateday, check_period) THEN IF checkdata THEN - RAISE EXCEPTION 'Reports_clean has not been updated to the end of %',updateday; + RAISE NOTICE 'Reports_clean has not been updated to the end of %',updateday; + RETURN FALSE; ELSE RAISE INFO 'reports_clean not updated'; RETURN FALSE; diff --git a/socorro/external/postgresql/raw_sql/procs/url2domain.sql b/socorro/external/postgresql/raw_sql/procs/url2domain.sql index 04965b8fb1..e3fcecdda7 100644 --- a/socorro/external/postgresql/raw_sql/procs/url2domain.sql +++ b/socorro/external/postgresql/raw_sql/procs/url2domain.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION url2domain(some_url text) RETURNS citext +CREATE OR REPLACE FUNCTION url2domain(some_url text) RETURNS citext LANGUAGE sql IMMUTABLE AS $_$ select substring($1 FROM $x$^([\w:]+:/+(?:\w+\.)*\w+).*$x$)::citext diff --git a/socorro/external/postgresql/raw_sql/procs/utc_day_is.sql b/socorro/external/postgresql/raw_sql/procs/utc_day_is.sql index 9f2ae702e7..85506746cb 100644 --- a/socorro/external/postgresql/raw_sql/procs/utc_day_is.sql +++ b/socorro/external/postgresql/raw_sql/procs/utc_day_is.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION utc_day_is(timestamp with time zone, timestamp without time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION utc_day_is(timestamp with time zone, timestamp without time zone) RETURNS boolean LANGUAGE sql IMMUTABLE AS $_$ select $1 >= ( $2 AT TIME ZONE 'UTC' ) diff --git a/socorro/external/postgresql/raw_sql/procs/utc_day_near.sql b/socorro/external/postgresql/raw_sql/procs/utc_day_near.sql index 5b21336310..4a17570f8f 100644 --- a/socorro/external/postgresql/raw_sql/procs/utc_day_near.sql +++ b/socorro/external/postgresql/raw_sql/procs/utc_day_near.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION utc_day_near(timestamp with time zone, timestamp without time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION utc_day_near(timestamp with time zone, timestamp without time zone) RETURNS boolean LANGUAGE sql IMMUTABLE AS $_$ select $1 > ( $2 AT TIME ZONE 'UTC' - INTERVAL '1 day' ) diff --git a/socorro/external/postgresql/raw_sql/procs/validate_lookup.sql b/socorro/external/postgresql/raw_sql/procs/validate_lookup.sql index c0eac1eec7..4e72bc5976 100644 --- a/socorro/external/postgresql/raw_sql/procs/validate_lookup.sql +++ b/socorro/external/postgresql/raw_sql/procs/validate_lookup.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION validate_lookup(ltable text, lcol text, lval text, lmessage text) RETURNS boolean +CREATE OR REPLACE FUNCTION validate_lookup(ltable text, lcol text, lval text, lmessage text) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE nrows INT; @@ -10,7 +10,8 @@ BEGIN IF nrows > 0 THEN RETURN true; ELSE - RAISE EXCEPTION '% is not a valid %',lval,lmessage; + RAISE NOTICE '% is not a valid %',lval,lmessage; + RETURN FALSE; END IF; END; $$; diff --git a/socorro/external/postgresql/raw_sql/procs/version_matches_channel.sql b/socorro/external/postgresql/raw_sql/procs/version_matches_channel.sql index 55ea64ef98..8e78d3923f 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_matches_channel.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_matches_channel.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_matches_channel(version text, channel citext) RETURNS boolean +CREATE OR REPLACE FUNCTION version_matches_channel(version text, channel citext) RETURNS boolean LANGUAGE sql IMMUTABLE STRICT AS $_$ SELECT CASE WHEN $1 ILIKE '%a1' AND $2 ILIKE 'nightly%' diff --git a/socorro/external/postgresql/raw_sql/procs/version_sort.sql b/socorro/external/postgresql/raw_sql/procs/version_sort.sql index 61e52c94c0..5bd3f2f4a0 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_sort.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_sort.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_sort(version text, beta_no integer DEFAULT 0, channel citext DEFAULT ''::citext) RETURNS text +CREATE OR REPLACE FUNCTION version_sort(version text, beta_no integer DEFAULT 0, channel citext DEFAULT ''::citext) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ DECLARE vne TEXT[]; diff --git a/socorro/external/postgresql/raw_sql/procs/version_sort_trigger.sql b/socorro/external/postgresql/raw_sql/procs/version_sort_trigger.sql index dccc5e38e5..20359c3826 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_sort_trigger.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_sort_trigger.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_sort_trigger() RETURNS trigger +CREATE OR REPLACE FUNCTION version_sort_trigger() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_after.sql b/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_after.sql index c5f3dd40ca..a6f98e2459 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_after.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_after.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_sort_update_trigger_after() RETURNS trigger +CREATE OR REPLACE FUNCTION version_sort_update_trigger_after() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_before.sql b/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_before.sql index 81b1738115..e016b6a222 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_before.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_sort_update_trigger_before.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_sort_update_trigger_before() RETURNS trigger +CREATE OR REPLACE FUNCTION version_sort_update_trigger_before() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN diff --git a/socorro/external/postgresql/raw_sql/procs/version_string.sql b/socorro/external/postgresql/raw_sql/procs/version_string.sql index 861eeb5c76..f9e99efc3a 100644 --- a/socorro/external/postgresql/raw_sql/procs/version_string.sql +++ b/socorro/external/postgresql/raw_sql/procs/version_string.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION version_string(version text, beta_number integer) RETURNS text +CREATE OR REPLACE FUNCTION version_string(version text, beta_number integer) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- converts a stripped version and a beta number @@ -11,7 +11,7 @@ END; $_$; -CREATE FUNCTION version_string(version text, beta_number integer, channel text) RETURNS text +CREATE OR REPLACE FUNCTION version_string(version text, beta_number integer, channel text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- converts a stripped version and a beta number diff --git a/socorro/external/postgresql/raw_sql/procs/watch_report_processing.sql b/socorro/external/postgresql/raw_sql/procs/watch_report_processing.sql index 1098a718ad..367dddb8b2 100644 --- a/socorro/external/postgresql/raw_sql/procs/watch_report_processing.sql +++ b/socorro/external/postgresql/raw_sql/procs/watch_report_processing.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION watch_report_processing(INOUT run_min integer, OUT report_count integer, OUT min_time interval, OUT max_time interval, OUT avg_time interval) RETURNS record +CREATE OR REPLACE FUNCTION watch_report_processing(INOUT run_min integer, OUT report_count integer, OUT min_time interval, OUT max_time interval, OUT avg_time interval) RETURNS record LANGUAGE plpgsql AS $$ declare reprec RECORD; diff --git a/socorro/external/postgresql/raw_sql/procs/week_begins_partition.sql b/socorro/external/postgresql/raw_sql/procs/week_begins_partition.sql index 8f795efc53..7a5939acbb 100644 --- a/socorro/external/postgresql/raw_sql/procs/week_begins_partition.sql +++ b/socorro/external/postgresql/raw_sql/procs/week_begins_partition.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION week_begins_partition(partname text) RETURNS timestamp with time zone +CREATE OR REPLACE FUNCTION week_begins_partition(partname text) RETURNS timestamp with time zone LANGUAGE sql IMMUTABLE SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/week_begins_partition_string.sql b/socorro/external/postgresql/raw_sql/procs/week_begins_partition_string.sql index 0b24c7f2dc..9c6e0037c8 100644 --- a/socorro/external/postgresql/raw_sql/procs/week_begins_partition_string.sql +++ b/socorro/external/postgresql/raw_sql/procs/week_begins_partition_string.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION week_begins_partition_string(partname text) RETURNS text +CREATE OR REPLACE FUNCTION week_begins_partition_string(partname text) RETURNS text LANGUAGE sql IMMUTABLE SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/week_begins_utc.sql b/socorro/external/postgresql/raw_sql/procs/week_begins_utc.sql index b0d9ea2551..eca60145b0 100644 --- a/socorro/external/postgresql/raw_sql/procs/week_begins_utc.sql +++ b/socorro/external/postgresql/raw_sql/procs/week_begins_utc.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION week_begins_utc(timestamp with time zone) RETURNS timestamp with time zone +CREATE OR REPLACE FUNCTION week_begins_utc(timestamp with time zone) RETURNS timestamp with time zone LANGUAGE sql STABLE SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/week_ends_partition.sql b/socorro/external/postgresql/raw_sql/procs/week_ends_partition.sql index 8c52d99bd9..15c3535d80 100644 --- a/socorro/external/postgresql/raw_sql/procs/week_ends_partition.sql +++ b/socorro/external/postgresql/raw_sql/procs/week_ends_partition.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION week_ends_partition(partname text) RETURNS timestamp with time zone +CREATE OR REPLACE FUNCTION week_ends_partition(partname text) RETURNS timestamp with time zone LANGUAGE sql IMMUTABLE SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/week_ends_partition_string.sql b/socorro/external/postgresql/raw_sql/procs/week_ends_partition_string.sql index 1d83bf8d9b..0bb607e38e 100644 --- a/socorro/external/postgresql/raw_sql/procs/week_ends_partition_string.sql +++ b/socorro/external/postgresql/raw_sql/procs/week_ends_partition_string.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION week_ends_partition_string(partname text) RETURNS text +CREATE OR REPLACE FUNCTION week_ends_partition_string(partname text) RETURNS text LANGUAGE sql IMMUTABLE SET "TimeZone" TO 'UTC' AS $_$ diff --git a/socorro/external/postgresql/raw_sql/procs/weekly_report_partitions.sql b/socorro/external/postgresql/raw_sql/procs/weekly_report_partitions.sql index 3e68a03312..8146d4312e 100644 --- a/socorro/external/postgresql/raw_sql/procs/weekly_report_partitions.sql +++ b/socorro/external/postgresql/raw_sql/procs/weekly_report_partitions.sql @@ -1,4 +1,4 @@ -CREATE FUNCTION weekly_report_partitions(numweeks integer DEFAULT 2, targetdate timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS boolean +CREATE OR REPLACE FUNCTION weekly_report_partitions(numweeks integer DEFAULT 2, targetdate timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS boolean LANGUAGE plpgsql AS $$ -- this function checks that we have partitions two weeks into diff --git a/socorro/unittest/lib/test_buildutil.py b/socorro/unittest/lib/test_buildutil.py index e003ff7e57..da180db84c 100644 --- a/socorro/unittest/lib/test_buildutil.py +++ b/socorro/unittest/lib/test_buildutil.py @@ -109,11 +109,8 @@ def test_insert_build(self): self.assertTrue(actual) # Test 2: fail at inserting a build - self.assertRaises( - psycopg2.Error, - buildutil.insert_build, - *(cursor, 'Unknown', 'VERSIONAME5', 'PLATFORMNAME5', - '20110101', 'Release', '5', 'REPO5')) + buildutil.insert_build(cursor, 'Unknown', 'VERSIONAME5', 'PLATFORMNAME5', + '20110101', 'Release', '5', 'REPO5') actual = self.build_exists(cursor, 'Unknown', 'VERSIONAME5', 'PLATFORMNAME5', '20110101', 'Release', '5', 'REPO5')