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

Function initializeInput

src/bin/psql/input.c:345–395  ·  view source on GitHub ↗

* Put any startup stuff related to input in here. It's good to maintain * abstraction this way. * * The only "flag" right now is 1 for use readline & history. */

Source from the content-addressed store, hash-verified

343 * The only "flag" right now is 1 for use readline & history.
344 */
345void
346initializeInput(int flags)
347{
348#ifdef USE_READLINE
349 if (flags & 1)
350 {
351 const char *histfile;
352 char home[MAXPGPATH];
353
354 useReadline = true;
355
356 /* these two things must be done in this order: */
357 initialize_readline();
358 rl_initialize();
359
360 useHistory = true;
361 using_history();
362 history_lines_added = 0;
363
364 histfile = GetVariable(pset.vars, "HISTFILE");
365
366 if (histfile == NULL)
367 {
368 char *envhist;
369
370 envhist = getenv("PSQL_HISTORY");
371 if (envhist != NULL && strlen(envhist) > 0)
372 histfile = envhist;
373 }
374
375 if (histfile == NULL)
376 {
377 if (get_home_path(home))
378 psql_history = psprintf("%s/%s", home, PSQLHISTORY);
379 }
380 else
381 {
382 psql_history = pg_strdup(histfile);
383 expand_tilde(&psql_history);
384 }
385
386 if (psql_history)
387 {
388 read_history(psql_history);
389 decode_history();
390 }
391 }
392#endif
393
394 atexit(finishInput);
395}
396
397
398/*

Callers 1

mainFunction · 0.85

Calls 7

initialize_readlineFunction · 0.85
GetVariableFunction · 0.85
get_home_pathFunction · 0.85
psprintfFunction · 0.85
pg_strdupFunction · 0.85
expand_tildeFunction · 0.85
decode_historyFunction · 0.85

Tested by

no test coverage detected