diff options
author | Marko Kreen | 2010-12-14 12:48:19 +0000 |
---|---|---|
committer | Marko Kreen | 2010-12-14 12:48:19 +0000 |
commit | 860de72318eb3f48d493e341e16d532803ebc118 (patch) | |
tree | 4da52b6cdfecbb5a4797b35e9b5683210518da3d | |
parent | 0cd27d11053d295cdd0c3773a81c303569f9b8d6 (diff) |
pgq: avoid text||int concet, it breaks if db has bandaid casts installed
-rw-r--r-- | sql/pgq/functions/pgq.batch_event_sql.sql | 18 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.batch_event_tables.sql | 4 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.batch_retry.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.create_queue.sql | 12 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.current_event_table.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.drop_queue.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.event_retry.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.get_batch_cursor.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.grant_perms.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.maint_rotate_tables.sql | 2 | ||||
-rw-r--r-- | sql/pgq/functions/pgq.tune_storage.sql | 2 |
11 files changed, 25 insertions, 25 deletions
diff --git a/sql/pgq/functions/pgq.batch_event_sql.sql b/sql/pgq/functions/pgq.batch_event_sql.sql index 043a3caa..1ed7c5ac 100644 --- a/sql/pgq/functions/pgq.batch_event_sql.sql +++ b/sql/pgq/functions/pgq.batch_event_sql.sql @@ -79,9 +79,9 @@ begin batch.tx_start := rec.id1; else if arr = '' then - arr := rec.id1; + arr := rec.id1::text; else - arr := arr || ',' || rec.id1; + arr := arr || ',' || rec.id1::text; end if; end if; end loop; @@ -90,7 +90,7 @@ begin select_fields := 'select ev_id, ev_time, ev_txid, ev_retry, ev_type,' || ' ev_data, ev_extra1, ev_extra2, ev_extra3, ev_extra4'; retry_expr := ' and (ev_owner is null or ev_owner = ' - || batch.sub_id || ')'; + || batch.sub_id::text || ')'; -- now generate query that goes over all potential tables sql := ''; @@ -101,12 +101,12 @@ begin -- this gets newer queries that definitely are not in prev_snapshot part := select_fields || ' from pgq.tick cur, pgq.tick last, ' || tbl || ' ev ' - || ' where cur.tick_id = ' || batch.sub_next_tick - || ' and cur.tick_queue = ' || batch.sub_queue - || ' and last.tick_id = ' || batch.sub_last_tick - || ' and last.tick_queue = ' || batch.sub_queue - || ' and ev.ev_txid >= ' || batch.tx_start - || ' and ev.ev_txid <= ' || batch.tx_end + || ' where cur.tick_id = ' || batch.sub_next_tick::text + || ' and cur.tick_queue = ' || batch.sub_queue::text + || ' and last.tick_id = ' || batch.sub_last_tick::text + || ' and last.tick_queue = ' || batch.sub_queue::text + || ' and ev.ev_txid >= ' || batch.tx_start::text + || ' and ev.ev_txid <= ' || batch.tx_end::text || ' and txid_visible_in_snapshot(ev.ev_txid, cur.tick_snapshot)' || ' and not txid_visible_in_snapshot(ev.ev_txid, last.tick_snapshot)' || retry_expr; diff --git a/sql/pgq/functions/pgq.batch_event_tables.sql b/sql/pgq/functions/pgq.batch_event_tables.sql index fd8cbd65..618fd656 100644 --- a/sql/pgq/functions/pgq.batch_event_tables.sql +++ b/sql/pgq/functions/pgq.batch_event_tables.sql @@ -51,12 +51,12 @@ begin if nr < 0 then nr := batch.queue_ntables - 1; end if; - tbl := batch.queue_data_pfx || '_' || nr; + tbl := batch.queue_data_pfx || '_' || nr::text; return next tbl; end if; if use_next then - tbl := batch.queue_data_pfx || '_' || batch.queue_cur_table; + tbl := batch.queue_data_pfx || '_' || batch.queue_cur_table::text; return next tbl; end if; diff --git a/sql/pgq/functions/pgq.batch_retry.sql b/sql/pgq/functions/pgq.batch_retry.sql index 09bd67c9..d4eb5d2c 100644 --- a/sql/pgq/functions/pgq.batch_retry.sql +++ b/sql/pgq/functions/pgq.batch_retry.sql @@ -19,7 +19,7 @@ declare _cnt integer; _s record; begin - _retry := current_timestamp + ((i_retry_seconds || ' seconds')::interval); + _retry := current_timestamp + ((i_retry_seconds::text || ' seconds')::interval); select * into _s from pgq.subscription where sub_batch = i_batch_id; if not found then diff --git a/sql/pgq/functions/pgq.create_queue.sql b/sql/pgq/functions/pgq.create_queue.sql index 46ddf9b0..b8323872 100644 --- a/sql/pgq/functions/pgq.create_queue.sql +++ b/sql/pgq/functions/pgq.create_queue.sql @@ -32,10 +32,10 @@ begin -- insert event id := nextval('pgq.queue_queue_id_seq'); - tblpfx := 'pgq.event_' || id; - idxpfx := 'event_' || id; - tick_seq := 'pgq.event_' || id || '_tick_seq'; - ev_seq := 'pgq.event_' || id || '_id_seq'; + tblpfx := 'pgq.event_' || id::text; + idxpfx := 'event_' || id::text; + tick_seq := 'pgq.event_' || id::text || '_tick_seq'; + ev_seq := 'pgq.event_' || id::text || '_id_seq'; insert into pgq.queue (queue_id, queue_name, queue_data_pfx, queue_event_seq, queue_tick_seq) values (id, i_queue_name, tblpfx, ev_seq, tick_seq); @@ -51,8 +51,8 @@ begin execute 'CREATE TABLE ' || tblpfx || ' () ' || ' INHERITS (pgq.event_template)'; for i in 0 .. (n_tables - 1) loop - tblname := tblpfx || '_' || i; - idxname := idxpfx || '_' || i; + tblname := tblpfx || '_' || i::text; + idxname := idxpfx || '_' || i::text; execute 'CREATE TABLE ' || tblname || ' () ' || ' INHERITS (' || tblpfx || ')'; execute 'ALTER TABLE ' || tblname || ' ALTER COLUMN ev_id ' diff --git a/sql/pgq/functions/pgq.current_event_table.sql b/sql/pgq/functions/pgq.current_event_table.sql index 3e4d74fb..6fecd422 100644 --- a/sql/pgq/functions/pgq.current_event_table.sql +++ b/sql/pgq/functions/pgq.current_event_table.sql @@ -20,7 +20,7 @@ declare res text; disabled boolean; begin - select queue_data_pfx || '_' || queue_cur_table, + select queue_data_pfx || '_' || queue_cur_table::text, queue_disable_insert into res, disabled from pgq.queue where queue_name = x_queue_name; diff --git a/sql/pgq/functions/pgq.drop_queue.sql b/sql/pgq/functions/pgq.drop_queue.sql index 6784fbb1..de2ba29f 100644 --- a/sql/pgq/functions/pgq.drop_queue.sql +++ b/sql/pgq/functions/pgq.drop_queue.sql @@ -36,7 +36,7 @@ begin -- drop data tables for i in 0 .. (q.queue_ntables - 1) loop - tblname := q.queue_data_pfx || '_' || i; + tblname := q.queue_data_pfx || '_' || i::text; execute 'DROP TABLE ' || tblname; end loop; execute 'DROP TABLE ' || q.queue_data_pfx; diff --git a/sql/pgq/functions/pgq.event_retry.sql b/sql/pgq/functions/pgq.event_retry.sql index ee54d3a1..54e94990 100644 --- a/sql/pgq/functions/pgq.event_retry.sql +++ b/sql/pgq/functions/pgq.event_retry.sql @@ -61,7 +61,7 @@ returns integer as $$ declare new_retry timestamptz; begin - new_retry := current_timestamp + ((x_retry_seconds || ' seconds')::interval); + new_retry := current_timestamp + ((x_retry_seconds::text || ' seconds')::interval); return pgq.event_retry(x_batch_id, x_event_id, new_retry); end; $$ language plpgsql security definer; diff --git a/sql/pgq/functions/pgq.get_batch_cursor.sql b/sql/pgq/functions/pgq.get_batch_cursor.sql index b1bb513e..8cc7d1fd 100644 --- a/sql/pgq/functions/pgq.get_batch_cursor.sql +++ b/sql/pgq/functions/pgq.get_batch_cursor.sql @@ -46,7 +46,7 @@ begin -- return first block of events for ev_id, ev_time, ev_txid, ev_retry, ev_type, ev_data, ev_extra1, ev_extra2, ev_extra3, ev_extra4 - in execute 'fetch ' || i_quick_limit || ' from ' || _cname + in execute 'fetch ' || i_quick_limit::text || ' from ' || _cname loop return next; end loop; diff --git a/sql/pgq/functions/pgq.grant_perms.sql b/sql/pgq/functions/pgq.grant_perms.sql index dc2e53df..afabfa5c 100644 --- a/sql/pgq/functions/pgq.grant_perms.sql +++ b/sql/pgq/functions/pgq.grant_perms.sql @@ -48,7 +48,7 @@ begin -- real event tables for i in 0 .. q.queue_ntables - 1 loop execute 'grant ' || tbl_perms - || ' on ' || q.queue_data_pfx || '_' || i + || ' on ' || q.queue_data_pfx || '_' || i::text || ' to public'; end loop; diff --git a/sql/pgq/functions/pgq.maint_rotate_tables.sql b/sql/pgq/functions/pgq.maint_rotate_tables.sql index 4ac6e8f2..d972a04e 100644 --- a/sql/pgq/functions/pgq.maint_rotate_tables.sql +++ b/sql/pgq/functions/pgq.maint_rotate_tables.sql @@ -57,7 +57,7 @@ begin if nr = cf.queue_ntables then nr := 0; end if; - tbl := cf.queue_data_pfx || '_' || nr; + tbl := cf.queue_data_pfx || '_' || nr::text; -- there may be long lock on the table from pg_dump, -- detect it and skip rotate then diff --git a/sql/pgq/functions/pgq.tune_storage.sql b/sql/pgq/functions/pgq.tune_storage.sql index 25f14317..5d81c857 100644 --- a/sql/pgq/functions/pgq.tune_storage.sql +++ b/sql/pgq/functions/pgq.tune_storage.sql @@ -22,7 +22,7 @@ begin end if; for i in 0 .. (q.queue_ntables - 1) loop - tbl := q.queue_data_pfx || '_' || i; + tbl := q.queue_data_pfx || '_' || i::text; -- set fillfactor sql := 'alter table ' || tbl || ' set (fillfactor = 100'; |