Some parameters of the China-domestically developed GBase 8a MPP database from GBASE can be set at session level, so they affect only the current connection. Because connection pools reuse connections, a changed value can leak into later SQL, so the safe pattern is to save the current value first, change it, then restore the saved value when done.
Saving the current value
Read the parameter with @@ and store it in a backup variable with set:
gbase> select @@estimate_func_max_len;
+-------------------------+
| @@estimate_func_max_len |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (Elapsed: 00:00:00.00)
gbase> set @bak=@@estimate_func_max_len;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
Changing the value
Set the new value and confirm it with show variables:
gbase> set estimate_func_max_len=32700;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> show variables like 'esti%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| estimate_func_max_len | 32700 |
+-----------------------+-------+
1 row in set (Elapsed: 00:00:00.00)
Restoring the value
Put the saved value back and confirm it returns to 0:
gbase> set estimate_func_max_len=@bak;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> show variables like 'esti%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| estimate_func_max_len | 0 |
+-----------------------+-------+
1 row in set (Elapsed: 00:00:00.00)
Going forward, treat a session-level change on a gbase cluster as borrow-and-return: read @@param into @bak before set, and restore it in the same connection. That keeps a gbase database predictable for the next statement the pool hands that connection to.
Top comments (0)