PostgreSQL metacommands lazarus / 16-Databases ---------------------------------------------------------------------- Elmug · 2012-06-21 11:42 Hi everyone, If anyone knows how to send meta-commands to the PostgreSQL engine, from a Lazarus application, I would appreciate some guidance. Thanks! ---------------------------------------------------------------------- goodname · 2012-06-21 12:57 I'm guessing that meta commands means "alter" or other commands that do not have to due with data manipulation. Just use ExecSQL or ExecuteDirect. ---------------------------------------------------------------------- Elmug · 2012-06-21 14:01 Quote from: goodname on June 21, 2012, 02:57:02 pmI'm guessing that meta commands means "alter" or other commands that do not have to due with data manipulation. Just use ExecSQL or ExecuteDirect. goodname, the metacommands start with the backslash (\) and they are not quite the same as "queries". I will check on what you say, though. Thanks. ---------------------------------------------------------------------- BigChimp · 2012-06-21 14:09 I think he means this: http://www.postgresql.org/docs/current/static/app-psql.html QuoteAnything you enter in psql that begins with an unquoted backslash is a psql meta-command that is processed by psql itself. Edit:In other words, the postgresql server never even receives these "commands"; they're specific to the command line psql program. ---------------------------------------------------------------------- Elmug · 2012-06-21 14:26 Quote from: BigChimp on June 21, 2012, 04:09:29 pmI think he means this: http://www.postgresql.org/docs/current/static/app-psql.html QuoteAnything you enter in psql that begins with an unquoted backslash is a psql meta-command that is processed by psql itself. In other words, the postgresql server never even receives these "commands"; they're specific to the command line psql program. BigChimp, Some commands do reach the server. For instance: \password [ username ]     Changes the password of the specified user (by default, the current user). This command prompts for the new password, encrypts it, and sends it to the server as an ALTER ROLE command. This makes sure that the new password does not appear in cleartext in the command history, the server log, or elsewhere. There are others. ---------------------------------------------------------------------- BigChimp · 2012-06-21 14:27 Thanks for the correction Elmug, you're right ---------------------------------------------------------------------- goodname · 2012-06-21 14:50 Even in the case of the psql \password meta command it looks like psql client is doing a lot of work to prepare the "alter" command. I can see how using psql \password would be useful and would be interested in seeing your solution if you find one. ---------------------------------------------------------------------- Elmug · 2012-06-21 15:35 Quote from: goodname on June 21, 2012, 04:50:04 pmEven in the case of the psql \password meta command it looks like psql client is doing a lot of work to prepare the "alter" command. I can see how using psql \password would be useful and would be interested in seeing your solution if you find one. Hi goodname, and other helpers, I am working on this approach right now: 1. At Lazarus application, have a box to specify PARAMETERS. 2. Using the PROCESS unit, create a PROCESSpgSQL:=TProcess; 3. TProcess:='pgSQL.exe PARAMETERS'..... Also, with path to wherever pgSQL.exe is located, of course (or copy it to folder with resultant  lazarus application ) Here, PARAMETERS means whatever it takes to start pgSQL as needed, including the redirection of its ouput to pgOutput.txt. This way, I believe I will also solve the capability of sending BOTH QUERIES that can be audited BEFORE sending, and also have the capability to send META-COMMANDS, and to read pgOutput.txt in a second memobox. So there will actually be 3 boxes used. One for parameters, one for the input query (which can now send metacommands), and one memo box to put the contents of the pgOutput.txt. Right now, I don't see why it wouldn't work. All this remains client- based. NOTE: PARAMETERS will also include whatever it takes to run pgSQL.exe in silent mode, meaning that the application user will NEVER see the pgSQL shell screen. Please let me know of opinion/corrections. Thanks.