MCPcopy Create free account
hub / github.com/apache/cloudberry / chooseScript

Function chooseScript

src/bin/pgbench/pgbench.c:2854–2870  ·  view source on GitHub ↗

return a script number with a weighted choice. */

Source from the content-addressed store, hash-verified

2852
2853/* return a script number with a weighted choice. */
2854static int
2855chooseScript(TState *thread)
2856{
2857 int i = 0;
2858 int64 w;
2859
2860 if (num_scripts == 1)
2861 return 0;
2862
2863 w = getrand(&thread->ts_choose_rs, 0, total_weight - 1);
2864 do
2865 {
2866 w -= sql_script[i++].weight;
2867 } while (w >= 0);
2868
2869 return i - 1;
2870}
2871
2872/* Send a SQL command, using the chosen querymode */
2873static bool

Callers 1

advanceConnectionStateFunction · 0.85

Calls 1

getrandFunction · 0.85

Tested by

no test coverage detected