Skip site navigation (1) Skip section navigation (2)

[PATCH] Return command tag 'REPLACE X' for CREATE OR REPLACE statements.

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Return command tag 'REPLACE X' for CREATE OR REPLACE statements.
Date: 2010-11-28 15:14:53
Message-ID: AANLkTi=_tE7970W86mCdQBT5S7L9zBEKaNykLYOdHQbS@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi list,

Often enough when developing PostgreSQL views and functions, I have
pasted the CREATE OR REPLACE commands into the wrong window/shell and
ran them there without realizing that I'm creating a function in the
wrong database, instead of replacing. Currently psql does not provide
any feedback of which action really occured.

Only after writing this patch I realized that I could instead raise a
NOTICE, like current IF EXISTS/IF NOT EXISTS clauses do. Is that a
better way to solve this?

This patch returns command tag "CREATE X" or "REPLACE X" for
LANGAUGE/VIEW/RULE/FUNCTION. This is done by passing completionTag to
from ProcessUtility to more functions, and adding a 'bool *didUpdate'
argument to some lower-level functions. I'm not sure if passing back
the status in a bool* is considered good style, but this way all the
functions look consistent.

Regards,
Marti

Attachment: 0001-Return-command-tag-REPLACE-X-for-CREATE-OR-REPLACE-s.patch
Description: text/x-patch (13.6 KB)

Responses

pgsql-hackers by date

Next:From: Josh KupershmidtDate: 2010-11-28 15:34:21
Subject: Re: [GENERAL] column-level update privs + lock table
Previous:From: Martijn van OosterhoutDate: 2010-11-28 14:45:54
Subject: Re: Rethinking representation of sort/hash semantics inqueries and plans

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group