"David G. Johnston" <david.g.johnston@xxxxxxxxx> writes: > Watch is documented to act on either a non-empty query buffer or the last > sent command. I would expect that whatever the final SQL command present > in x.sql is would be the command that gets watched. If indeed the > preceding select 1 command is watched there would seem to be an > undocumented interaction going on. It looks like there's a separate query_buf for each recursive level of MainLoop(), that is, each level of \i. So maybe the docs need improvement here. (I think the actual behavior is probably fine.) regards, tom lane