this is actually bearable with \set verbosity terse
[migration-tools.git] / sql / base / base.sql
index 8141a3b..3366cd8 100644 (file)
@@ -57,6 +57,7 @@ CREATE OR REPLACE FUNCTION migration_tools.exec (TEXT,TEXT) RETURNS VOID AS $$
         nrows INTEGER;
     BEGIN
         EXECUTE 'UPDATE ' || migration_schema || '.sql_current SET sql = ' || quote_literal(sql) || ';';
+        --RAISE INFO '%', sql;
         EXECUTE sql;
         GET DIAGNOSTICS nrows = ROW_COUNT;
         PERFORM migration_tools.log(migration_schema,sql,nrows);
@@ -227,7 +228,7 @@ CREATE OR REPLACE FUNCTION migration_tools.rebarcode (o TEXT, t BIGINT) RETURNS
     DECLARE
         n TEXT := o;
     BEGIN
-        IF o ~ E'^\\d+$' AND o !~ E'^0' THEN
+        IF o ~ E'^\\d+$' AND o !~ E'^0' AND length(o) < 19 THEN -- for reference, the max value for a bigint is 9223372036854775807.  May also want to consider the case where folks want to add prefixes to non-numeric barcodes
             IF o::BIGINT < t THEN
                 n = o::BIGINT + t;
             END IF;