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

Function initGenerateDataServerSide

src/bin/pgbench/pgbench.c:4309–4349  ·  view source on GitHub ↗

* Fill the standard tables with some data generated on the server * * As already the case with the client-side data generation, the filler * column defaults to NULL in pgbench_branches and pgbench_tellers, * and is a blank-padded string in pgbench_accounts. */

Source from the content-addressed store, hash-verified

4307 * and is a blank-padded string in pgbench_accounts.
4308 */
4309static void
4310initGenerateDataServerSide(PGconn *con)
4311{
4312 PQExpBufferData sql;
4313
4314 fprintf(stderr, "generating data (server-side)...\n");
4315
4316 /*
4317 * we do all of this in one transaction to enable the backend's
4318 * data-loading optimizations
4319 */
4320 executeStatement(con, "begin");
4321
4322 /* truncate away any old data */
4323 initTruncateTables(con);
4324
4325 initPQExpBuffer(&sql);
4326
4327 printfPQExpBuffer(&sql,
4328 "insert into pgbench_branches(bid,bbalance) "
4329 "select bid, 0 "
4330 "from generate_series(1, %d) as bid", nbranches * scale);
4331 executeStatement(con, sql.data);
4332
4333 printfPQExpBuffer(&sql,
4334 "insert into pgbench_tellers(tid,bid,tbalance) "
4335 "select tid, (tid - 1) / %d + 1, 0 "
4336 "from generate_series(1, %d) as tid", ntellers, ntellers * scale);
4337 executeStatement(con, sql.data);
4338
4339 printfPQExpBuffer(&sql,
4340 "insert into pgbench_accounts(aid,bid,abalance,filler) "
4341 "select aid, (aid - 1) / %d + 1, 0, '' "
4342 "from generate_series(1, " INT64_FORMAT ") as aid",
4343 naccounts, (int64) naccounts * scale);
4344 executeStatement(con, sql.data);
4345
4346 termPQExpBuffer(&sql);
4347
4348 executeStatement(con, "commit");
4349}
4350
4351/*
4352 * Invoke vacuum on the standard tables

Callers 1

runInitStepsFunction · 0.85

Calls 5

executeStatementFunction · 0.85
initTruncateTablesFunction · 0.85
initPQExpBufferFunction · 0.85
printfPQExpBufferFunction · 0.85
termPQExpBufferFunction · 0.85

Tested by

no test coverage detected