Re: The DROP TABLE instruction should have a TEMP option for when atemporary table
От | Pablo Benito |
---|---|
Тема | Re: The DROP TABLE instruction should have a TEMP option for when atemporary table |
Дата | |
Msg-id | CAME+NGWX2oozOrzuK=UVp_j185heLHzhJ8znjiQ8QBfsXRRsBQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: The DROP TABLE instruction should have a TEMP option for when a temporary table (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-docs |
Hi Tom,
Thanks a lot, for the response!
Yes, you are right, there is a secure way for drops, prefixing with the schema name.
But, for this particular case, TEMPORARY tables, as a special way for CREATE TABLE, It would be good to have also an special way for DROP TABLE.
(It is just an opinion)
Today I realized that,
and I've created my functions:
--/*
;CREATE FUNCTION "dailyDataProcessingEphemerals"."getTemporalSchemaName"()
RETURNS text
AS $$
SELECT quote_ident(nspname) FROM pg_namespace WHERE oid = pg_my_temp_schema();
$$ LANGUAGE SQL;
-- RUN AS: ;SELECT * FROM "dailyDataProcessingEphemerals"."getTemporalSchemaName"()
;CREATE FUNCTION "dailyDataProcessingEphemerals"."dropTemporalTableIfExists"("tableName" text)
RETURNS void
LANGUAGE "plpgsql"
AS $$
BEGIN
EXECUTE 'DROP TABLE IF EXISTS ' || (SELECT "getTemporalSchemaName" FROM "dailyDataProcessingEphemerals"."getTemporalSchemaName"()) || '.' || quote_ident("tableName");
END $$
--*/
Regards Pablo
El vie., 19 de oct. de 2018 a la(s) 21:33, Tom Lane (tgl@sss.pgh.pa.us) escribió:
PG Doc comments form <noreply@postgresql.org> writes:
> The issue is related to the intention of drop the temporary table:
> ;DROP TABLE "myTooImportantTable" -- <--- this drop the
> "myTooImportantTable"
> ;DROP TABLE "myTooImportantTable" -- <--- this drop the
> public."myTooImportantTable"
If you want to be sure you drop a temp table and not a regular one, say
DROP TABLE pg_temp.mytable;
There's no need for new syntax.
regards, tom lane
В списке pgsql-docs по дате отправления: