"SQL sentence"?

Started by Jim Nasbyalmost 9 years ago6 messages
#1Jim Nasby
Jim.Nasby@BlueTreble.com

I'm confused by this:

"pg_event_trigger_ddl_commands returns one row for each base command
executed; some commands that are a single SQL sentence may return more
than one row."

What is a "SQL sentence"?

(FWIW, I'm wondering because I was just looking to see why there's no
details for things like altering a column in a table.)
--
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
855-TREBLE2 (855-873-2532)

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

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Jim Nasby (#1)
Re: "SQL sentence"?

Jim Nasby wrote:

I'm confused by this:

"pg_event_trigger_ddl_commands returns one row for each base command
executed; some commands that are a single SQL sentence may return more than
one row."

What is a "SQL sentence"?

I meant "a single SQL command". The word "sentence" probably just
slipped through. Will fix.

(FWIW, I'm wondering because I was just looking to see why there's no
details for things like altering a column in a table.)

Do you mean you want to have access to the details of the alter table
operations being executed? There's no structured data for that; you
need to write a C function to examine the pg_ddl_command opaque column.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

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

#3Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Alvaro Herrera (#2)
Re: "SQL sentence"?

On 2/17/17 10:19 PM, Alvaro Herrera wrote:

(FWIW, I'm wondering because I was just looking to see why there's no
details for things like altering a column in a table.)

Do you mean you want to have access to the details of the alter table
operations being executed? There's no structured data for that; you
need to write a C function to examine the pg_ddl_command opaque column.

Yeah. It doesn't seem unreasonable for a user to want to get at that info.

Could the opaque column be mapped to a composite? I guess that'd be a
bit of a pain due to the union. :/ And I have a suspicion that
alterTable.subcmds is a list of CollectedCommand, making things more fun.
--
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
855-TREBLE2 (855-873-2532)

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

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Jim Nasby (#3)
Re: "SQL sentence"?

Jim Nasby wrote:

On 2/17/17 10:19 PM, Alvaro Herrera wrote:

(FWIW, I'm wondering because I was just looking to see why there's no
details for things like altering a column in a table.)

Do you mean you want to have access to the details of the alter table
operations being executed? There's no structured data for that; you
need to write a C function to examine the pg_ddl_command opaque column.

Yeah. It doesn't seem unreasonable for a user to want to get at that info.

Sure. We have the extension that turned the command into JSON. It's
still an unfinished patch, sadly, even though Alex Shulgin spent a lot
of effort trying to get it finished. It is still missing a nontrivial
amount of work, but within reach ISTM.

Could the opaque column be mapped to a composite?

No. If it could, we would just have added the fields to the output of
the function.

I guess that'd be a bit of
a pain due to the union. :/ And I have a suspicion that alterTable.subcmds
is a list of CollectedCommand, making things more fun.

The AT subcmds have their own struct, so it's even more fun than that.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

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

#5Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Alvaro Herrera (#4)
Re: "SQL sentence"?

On 2/17/17 10:46 PM, Alvaro Herrera wrote:

Jim Nasby wrote:

On 2/17/17 10:19 PM, Alvaro Herrera wrote:

(FWIW, I'm wondering because I was just looking to see why there's no
details for things like altering a column in a table.)

Do you mean you want to have access to the details of the alter table
operations being executed? There's no structured data for that; you
need to write a C function to examine the pg_ddl_command opaque column.

Yeah. It doesn't seem unreasonable for a user to want to get at that info.

Sure. We have the extension that turned the command into JSON. It's
still an unfinished patch, sadly, even though Alex Shulgin spent a lot
of effort trying to get it finished. It is still missing a nontrivial
amount of work, but within reach ISTM.

I wonder if there's some generic way we could make C structs to JSON.
IIRC there's other places where that ability would be handly.
--
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
855-TREBLE2 (855-873-2532)

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

#6Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Alvaro Herrera (#4)
Re: "SQL sentence"?

On 2/17/17 10:46 PM, Alvaro Herrera wrote:

Sure. We have the extension that turned the command into JSON. It's
still an unfinished patch, sadly, even though Alex Shulgin spent a lot
of effort trying to get it finished. It is still missing a nontrivial
amount of work, but within reach ISTM.

You're speaking of
/messages/by-id/CACACo5Q_UXYwF117LBhjZ3xaMPyrgqnqE=mXvRhEfjJ51aCfwQ@mail.gmail.com
? Can you reply to that to restart discussion?
--
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
855-TREBLE2 (855-873-2532)

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