Postgresql - Inline comment in VIEW Sql definition

Поиск
Список
Период
Сортировка
Искать

Postgresql - Inline comment in VIEW Sql definition

От:
vikram singh chandel <vikramschandel@outlook.com>
Дата:

Hello Team,

PostgreSQL does not allow to strore inline comments in view's SQL definition, because the CREATE VIEW statement is parsed, and then analyzed to see what table and other database objects are referenced, and then the analyzed parse-tree is saved.

However in our application we have designed one process which uses the tags that we mention within comments as part of CREATE VIEW definition. Things were going on good in Oracle database as it stored inline comments also. During migration we are unable to port one of our functionality which have dependency on comments in View in Postgres it didn't save the comments.

Do we have anyway to get the actual VIEW text in Postgres db.

Thanks

Vikram

Re: Postgresql - Inline comment in VIEW Sql definition

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
vikram singh chandel  writes:
> PostgreSQL does not allow to strore inline comments in view's SQL definition, because the CREATE VIEW statement is parsed, and then analyzed to see what table and other database objects are referenced, and then the analyzed parse-tree is saved.

> However in our application we have designed one process which uses the tags that we mention within comments as part of CREATE VIEW definition. Things were going on good in Oracle database as it stored inline comments also. During migration we are unable to port one of our functionality which have dependency on comments in View in Postgres it didn't save the comments.

> Do we have anyway to get the actual VIEW text in Postgres db.

No.  You might be able to achieve something more or less equivalent
using COMMENT ON to attach comments to the view's columns.

			regards, tom lane

Re: Postgresql - Inline comment in VIEW Sql definition

От:
Merlin Moncure <mmoncure@gmail.com>
Дата:
On Mon, Apr 4, 2016 at 9:10 AM, Tom Lane  wrote:
> vikram singh chandel  writes:
>> PostgreSQL does not allow to strore inline comments in view's SQL definition, because the CREATE VIEW statement is parsed, and then analyzed to see what table and other database objects are referenced, and then the analyzed parse-tree is saved.
>
>> However in our application we have designed one process which uses the tags that we mention within comments as part of CREATE VIEW definition. Things were going on good in Oracle database as it stored inline comments also. During migration we are unable to port one of our functionality which have dependency on comments in View in Postgres it didn't save the comments.
>
>> Do we have anyway to get the actual VIEW text in Postgres db.
>
> No.  You might be able to achieve something more or less equivalent
> using COMMENT ON to attach comments to the view's columns.

You can also wrap view creation in a function -- functions preserve
inline comments.

Generally though with postgres you want to write all DDL into scripts
rather than let the database manage the code.

merlin

Re: Postgresql - Inline comment in VIEW Sql definition

От:
vikram singh chandel <vikramschandel@outlook.com>
Дата:
Вложения:

Awaiting for your response


From: vikram singh chandel <vikramschandel@outlook.com>
Sent: Tuesday, April 5, 2016 1:17 PM
To: pgsql-novice@postgresql.org
Subject: Fw: Postgresql - Inline comment in VIEW Sql definition
 

Hi Team,


One more thing, I googled and found out few links related to "extending sql in PostgreSQL".

https://www.citusdata.com/blog/90-sql-scaling-and-whats-unique-about-postgres

www.citusdata.com
This blog post simplifies certain concepts to be brief. If you're looking for examples on how to override the PostgreSQL planner and executor, please check out pg ...

It has mentioned that "Fortunately, you can change any database submodule's behavior in Postgres by intercepting the right hook." Will it be possible to go through this approach.
Please suggest.

Thanks
Vikram


From: vikram singh chandel <vikramschandel@outlook.com>
Sent: Monday, April 4, 2016 7:01 PM
To: pgsql-novice@postgresql.org
Subject: Postgresql - Inline comment in VIEW Sql definition
 

Hello Team,

PostgreSQL does not allow to strore inline comments in view's SQL definition, because the CREATE VIEW statement is parsed, and then analyzed to see what table and other database objects are referenced, and then the analyzed parse-tree is saved.

However in our application we have designed one process which uses the tags that we mention within comments as part of CREATE VIEW definition. Things were going on good in Oracle database as it stored inline comments also. During migration we are unable to port one of our functionality which have dependency on comments in View in Postgres it didn't save the comments.

Do we have anyway to get the actual VIEW text in Postgres db.

Thanks

Vikram

Re: Postgresql - Inline comment in VIEW Sql definition

От:
Luca Ferrari <fluca1978@infinito.it>
Дата:
On Wed, Apr 6, 2016 at 4:41 PM, vikram singh chandel
 wrote:
>
> Awaiting for your response
>

As you can imagine, being Open Source, with a BSD License, well
documented, well written, you can surely go on your own and change the
way PostgreSQL handles SQL, indexes, storage, networking, replication
and so on.
But it seems to me a quite hard approach just to adapt it to something
your application requires.

Why setting comments on database object will not work for you?
Why not using some schema management tool (e.g., sqitch)?


Luca

FAQ