pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Greg Stark <stark@mit.edu>
Cc: Erik Rijkers <er@xs4all.nl>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: Jim Nasby <Jim.Nasby@bluetreble.com>
Cc: PostgreSQL <pgsql-hackers@postgresql.org>
Cc: pgsql-hackers-owner@postgresql.org
Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Date: Wed, 22 Feb 2017 16:00:50 -0500
Message-ID: <16856.1487797250@sss.pgh.pa.us> (raw)
In-Reply-To: <CADkLM=fxMCUf4zx2oEJfigLtdz8coF5QH7Ht4vJ6Lih+F=Kk=g@mail.gmail.com>
References: <CADkLM=dcMHeSOQZv0Dd8AO4cM+OzADg7u8PcA7d8pNezmLDo=g@mail.gmail.com>
	<24063.1486671184@sss.pgh.pa.us>
	<5095.1486674948@sss.pgh.pa.us>
	<4fb8635d88c7dc907d069e15fdd1ab94@xs4all.nl>
	<CADkLM=fbsnkWUWOKz8JiU5hN-8mKDm7MgsuAq6pHk-22eqJ3xA@mail.gmail.com>
	<alpine.DEB.2.20.1702100847180.27011@lancre>
	<CADkLM=dXgQTRDsyjCUZCh9LGKbNAnxM2weVq9uO4E7LfJg5P2Q@mail.gmail.com>
	<alpine.DEB.2.20.1702102217390.26448@lancre>
	<CAM-w4HMRumvzES_PaBD8b84b_LdhTyH__FAK6xwFBgwkTzvOsw@mail.gmail.com>
	<CADkLM=f4cDjWgq_JxMhf_NS0PG-xYuL5rhVpxth2zYxpu_fMhQ@mail.gmail.com>
	<CAM-w4HNhWn=suYQfhPOHyrg4_ub1OtT+oogfRNPnacWEBa6Ugw@mail.gmail.com>
	<alpine.DEB.2.20.1702120823010.26448@lancre>
	<CADkLM=fj9EOqCB89nJ7Qm9OKdrF9xL0qqaRq3VFa5=vO4faUzg@mail.gmail.com>
	<CADkLM=dZJ77XF=0pZMeQQkLYgHyXPs=bAg4+K0W+d-U5SbwAeg@mail.gmail.com>
	<CADkLM=decErx7iFyzxuPMQ5DNd6dearn+VuE1ajWKA_NaaMtug@mail.gmail.com>
	<28640.1487108678@sss.pgh.pa.us>
	<alpine.DEB.2.20.1702142349280.16120@lancre>
	<CADkLM=fxMCUf4zx2oEJfigLtdz8coF5! QH7Ht4vJ6Lih+F=Kk=g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Corey Huinker <corey.huinker@gmail.com> writes:
>> but if you think that it should be somewhere else, please advise Corey
>> about where to put it.

> Just a reminder that I'm standing by for advice.

Sorry, I'd lost track of this thread.

> The issue at hand is whether the if-state should be a part of the
> PsqlScanState, or if it should be a separate state variable owned by
> MainLoop() and passed to HandleSlashCommands(), ... or some other solution.

My reaction to putting it in PsqlScanState is pretty much "over my dead
body".  That's just trashing any pretense of an arms-length separation
between psql and the lexer proper.  We only recently got done sweating
blood to create that separation, why would we toss it away already?

If you're concerned about the notational overhead of passing two arguments
rather than one, my druthers would be to invent a new struct type, perhaps
named along the lines of PsqlFileState or PsqlInputState, and pass that
around.  One of its fields would be a PsqlScanState pointer, the rest
would be for if-state and whatever else we think we need in per-input-file
state.

However, that way is doubling down on the assumption that the if-state is
exactly one-to-one with input file levels, isn't it?  We might be better
off to just live with the separate arguments to preserve some flexibility
in that regard.  The v12 patch doesn't look that awful in terms of what
it's adding to argument lists.

One thing I'm wondering is why the "active_branch" bool is in "pset"
and not in the conditional stack.  That seems, at best, pretty grotty.
_psqlSettings is meant for reasonably persistent state.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (232+ messages)  latest in thread

Message-ID: <16856.1487797250@sss.pgh.pa.us>
Permalink:  ../16856.1487797250@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16856.1487797250@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, corey.huinker@gmail.com, coelho@cri.ensmp.fr, stark@mit.edu, er@xs4all.nl, robertmhaas@gmail.com, daniel@manitou-mail.org, Jim.Nasby@bluetreble.com, pgsql-hackers-owner@postgresql.org
  Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
  In-Reply-To: <16856.1487797250@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox