Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Can we pass a varchar/text datatype in to a variable in pgbench?

$
0
0

–pgbench sql script

[pg93@db1 load_test]$ cat get_email.sql 
setrandom cnt 1 100000
set v_username 'user_' || :cnt

begin;
select get_user_email(:v_username);
end;

get_user_email() is a function which can get user’s email.

–pgbench

[pg93@db1 load_test]$ nohup pgbench -c 4 -T 10 -d proxy -U proxy  -N -n -f get_email.sql  >  get_email.out  2>&1 &

–the get_email.out file says

nohup: ignoring input
client 0 executing setrandom cnt 1 100000
client 0 executing set v_username 'user_' || :cnt
invalid input syntax for integer: "'user_'"
invalid input syntax for integer: "'user_'"
set: unsupported operator ||

It’s seem that can only use integer datatype.

–data

db2=> select * from users limit 3;
 username |      email      
----------+-----------------
 user_6   | user_6@163.com
 user_19  | user_19@163.com
 user_20  | user_20@163.com

get_user_email() is a function which can get user’s email.


Viewing all articles
Browse latest Browse all 1138

Trending Articles