Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEAQE-0004JY-5G for pgsql-docs@arkaria.postgresql.org; Sun, 21 Oct 2018 09:53:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEAQB-0000mf-6F for pgsql-docs@arkaria.postgresql.org; Sun, 21 Oct 2018 09:53:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gE1l1-0007zY-22 for pgsql-docs@lists.postgresql.org; Sun, 21 Oct 2018 00:38:15 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gE1kx-00038Q-L6 for pgsql-docs@lists.postgresql.org; Sun, 21 Oct 2018 00:38:13 +0000 Received: by mail-lj1-x243.google.com with SMTP id u21-v6so33847935lja.8 for ; Sat, 20 Oct 2018 17:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QD5AU/NePhxUXw08Xmfkm6hvysV3uzAcWvDoyQ4fbRY=; b=E24PqCRmJLZD1Ow+Sd6LxfNlpC6DJxP3oDwld6ronw2tELNB1eJ4Q0bGy3fUK22H66 9iuNHFW7zvEoDptSEGQRciKxT/JiJGXVskOPnBZI6zT/YmiYbkB16ipokXoAJAT9TuIA S12x8Dc25wOAzSBsJYJtFddCREqpm14kXUR5rVn+4tWsPqBwbudPMHGixuyyopwffkc/ OuXDt65Gy6ygx1/b/uqDTuMhy3dS5qJJv7jViamZ544NWH0vBZZl1FyKPLEv42NIRXma x1xRrK+8TgascF84Cc1qMEkU1Hr5r9/HE1rZPSakQ9JcQ8sefiHtYTpLf6dNse5J4iCR 9ZMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QD5AU/NePhxUXw08Xmfkm6hvysV3uzAcWvDoyQ4fbRY=; b=LgFr6JwDfd/RYxnjMW4uNtebBGQNdGppkYIP1P1gaYHPnsFXaoBUs4RGaOEXHk23qg EXmFPoLyUI6eYUyjK9rGBIRl+J91Z1EUTHR3a6E514OL29uhpoG6d/T+tVaA9tQ/ssig gkm3moBlA06ygcG2Mf172v23oI0eZIIw1/k27gPEkUjNjl2sCPgALGLxnFRfNSUGEKDD 9wpvQvC6R6Lzhu/8APgYkx11W/A4OOE5blhNUujlnPwCfgyaQGEVVimbBIzE1vv3oqGy Z6OS9Zl40YBjEuJ3tIOeRUWAy/V1AxZvY5XUXzs9rzed4t7Ip2aolQM7tWGBuKUlWsYQ mAnw== X-Gm-Message-State: ABuFfoj7opa0O9EdWyY7K3XsmnI07zEApxHBylwZoYeGl0LY5g6gTzqh YKX9+ADydFtFFX4nU3R+mXxAHREkmlS1DL9TP/z428A= X-Google-Smtp-Source: ACcGV62sGKpM6mtSn7XfkuK8U75uUWw9C/OX9w3WtAsZmAJOQIvCJzuBNvu2WYSAT8C70oWrp/RNMK2Q/riIuvBBWzE= X-Received: by 2002:a2e:1241:: with SMTP id t62-v6mr25288850lje.81.1540082288231; Sat, 20 Oct 2018 17:38:08 -0700 (PDT) MIME-Version: 1.0 References: <153999002350.30914.3114277646917994661@wrigleys.postgresql.org> <22268.1539995600@sss.pgh.pa.us> In-Reply-To: <22268.1539995600@sss.pgh.pa.us> From: Pablo Benito Date: Sat, 20 Oct 2018 21:37:56 -0300 Message-ID: Subject: Re: The DROP TABLE instruction should have a TEMP option for when a temporary table To: tgl@sss.pgh.pa.us Cc: pgsql-docs@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b709860578b259a0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000b709860578b259a0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =3D 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=C3=B3: > =3D?utf-8?q?PG_Doc_comments_form?=3D 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 > --000000000000b709860578b259a0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 opini= on)

Today I realized that,
and I've = created my functions:

--/*
;CRE= ATE FUNCTION "dailyDataProcessingEphemerals"."getTemporalSch= emaName"()
RETURNS text
AS $$
SELECT quo= te_ident(nspname) FROM pg_namespace WHERE=C2=A0 oid =3D pg_my_temp_schema()= ;
$$ LANGUAGE SQL;

-- RUN AS: ;SELECT * = FROM "dailyDataProcessingEphemerals"."getTemporalSchemaName&= quot;()

;CREATE FUNCTION "dailyDataProcessing= Ephemerals"."dropTemporalTableIfExists"("tableName"= ; text)
RETURNS void
LANGUAGE "plpgsql"
=
AS $$
BEGIN
EXECUTE 'DROP TABLE IF EXISTS '= ; || (SELECT "getTemporalSchemaName" FROM "dailyDataProcessi= ngEphemerals"."getTemporalSchemaName"()) || '.' || q= uote_ident("tableName");
END $$
--*/


Regards Pablo

El vie., 19 de oct. de 2018 a la(s) 21:= 33, Tom Lane (tgl@sss.pgh.pa.us) e= scribi=C3=B3:
=3D?utf-8?q?PG_Doc_co= mments_form?=3D <noreply@postgresql.org> writes:
> The issue is related to the intention of drop the temporary table:
> ;DROP TABLE "myTooImportantTable"=C2=A0 =C2=A0-- <--- thi= s 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.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--000000000000b709860578b259a0--