Closed aleclarson closed 2 hours ago
I'm also not clear on why $0 initdb
is executed twice here:
EDIT: Nevermind, the git blame helped explain. It's initializing another database in advance for future calls to pg_tmp start
. Very cool! 😄
Hey! I'm porting your awesome utility to Node.js
Cool!
and I have a question about the NEW file.
Correct me if I'm wrong, but it appears that its absence will prevent reuse of an existing “datadir” (a temporary data directory). Does that mean once a datadir is “started” once, it can't be automatically reused ever again? (You know, because there won't be a NEW file present anymore.)
Yes, the NEW
file is used to indicate that pg_tmp
can grab this directory and start PostgreSQL, and other invocations of the script will ignore this directory.
Appreciate the quick reply!
To summarize what I've learned, the NEW
file helps facilitate the optimistic pg_tmp initdb
call that occurs in the background whenever pg_tmp start
runs without an explicit data directory provided.
Thanks for making ephemeralpg! :)
Hey! I'm porting your awesome utility to Node.js and I have a question about the
NEW
file.Correct me if I'm wrong, but it appears that its absence will prevent reuse of an existing “datadir” (a temporary data directory). Does that mean once a datadir is “started” once, it can't be automatically reused ever again? (You know, because there won't be a
NEW
file present anymore.)If that's true, that would mean calling
pg_tmp start
3 times in a row would create 3 separate temporary databases. Is that correct (and intentional)?Sorry if this all seems basic, but I'm making sure I understand it clearly. 😄
Related lines
Inside
initdb
: https://github.com/eradman/ephemeralpg/blob/ade77fce1594484039406b6b04ef1907540587c2/pg_tmp.sh#L65Inside
start
: https://github.com/eradman/ephemeralpg/blob/ade77fce1594484039406b6b04ef1907540587c2/pg_tmp.sh#L72-L78