Re: psql metaqueries with \gexec

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql metaqueries with \gexec
Date: 2016-02-22 22:49:16
Message-ID: 56CB906C.1020409@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/22/16 11:47 AM, Alvaro Herrera wrote:
> Pavel Stehule wrote:
>
>> The design of the "format" function is not closed. Try to send prototype
>> and patch. The possibility to do PostgreSQL customization was strong reason
>> why we didn't implemented "sprintf" and we implemented "format".
>
> Probably not terribly useful here, but for the DDL-deparse patch I came
> up with a syntax to format JSON objects, which used %-escapes; each
> escaped element corresponds to a string literal, or to an object. So
> you'd have %{table}D where the "table" element in the JSON object could
> be a simple string which is expanded verbatim (plus quoting if
> necessary), or it could be a JSON object with something like { schema =>
> "public", name => "students" }, where each element is expanded and
> quoted as necessary; if the "schema" is null or it doesn't exist, it
> expands only the name, obviously omitting the dot.

Where did the "D" in "%{table}D" come from?

BTW, the syntax I chose for [1] is similar to format's, except I elected
to stick with % instead of $. So you do

%parameter_name%type

where type is s, L or I. I don't think it'd be hard to support an object
with 'schema' and 'name' keys.

[1]
https://github.com/decibel/trunklet-format/blob/master/doc/trunklet-format.asc#2-template-specification
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vitaly Burovoy 2016-02-22 22:58:26 [PATH] Correct negative/zero year in to_date/to_timestamp
Previous Message Álvaro Hernández Tortosa 2016-02-22 22:42:33 Re: about google summer of code 2016