public inbox for [email protected]  
help / color / mirror / Atom feed
From: Thom Brown <[email protected]>
To: Dave Page <[email protected]>
Cc: Aditya Toshniwal <[email protected]>
Cc: Anil Sahoo <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: Regarding feature #6841
Date: Wed, 24 Apr 2024 14:42:45 +0100
Message-ID: <CAA-aLv4nVeTmGPTtEi15y+Pn-usOoY7KPu594QzQtF9ikG0yYg@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoxN3D+tojy+67LNc702oP2JrK9035HtSROYeJErb6EXqw@mail.gmail.com>
References: <CAO+oWtBxAaDxdPOkcf=bTU0D6sDogX_az4SgN-5zKZt-9G=2xQ@mail.gmail.com>
	<CA+OCxozieNmgfoGFq0G0Mxy+bu2Ct6hK9goZA3xtVJm9EaK6HA@mail.gmail.com>
	<CAO+oWtA13KM+jmWm+MkGbmLps2dh3B06mEZu6-PQjZ0ip7+G6g@mail.gmail.com>
	<CA+OCxoxMdX9Lsyugx7=_CZ3Z6K9jxHVTOBu4q=5_1cwgXsP7LQ@mail.gmail.com>
	<CAM9w-_mdXSmj2xv9W2k6hdmdY+3V8rfi4gnjBA_Jy28ZYkza2Q@mail.gmail.com>
	<CA+OCxozSdrD1ziKmfd_xLh72P031vdEo60wZxniyYP9sBLoM7Q@mail.gmail.com>
	<CAM9w-_=tRn_zM6C8Pm6B5w6du8BjdtrRnb1XxX1qyEcaSx4kEg@mail.gmail.com>
	<CA+OCxoz30kYxbska9TFHDKO3kXoervwY6OYE2kcY6b-k6-iYvg@mail.gmail.com>
	<CAM9w-_kjmG0rthcqss2TL+eFtC93qn_5ts_5=Fkqes82VG_EMg@mail.gmail.com>
	<CA+OCxozJpVhOTkPMv3_+EoEto+v+EeL=p1-dxjHFEvJM1EMBEQ@mail.gmail.com>
	<CAM9w-_n9i5fZSzRRNywJiCGv7TSRbSHLv+LVEBR=qn3zczrAxg@mail.gmail.com>
	<CAM9w-_nvA83wZ8m47B3fLswAQygrg1X9tk1g9hyQZEFqoH_zog@mail.gmail.com>
	<CA+OCxowig3kDr7APS0jitjBcE=Mq_vbnUNYYApt6-7_xp9yg6w@mail.gmail.com>
	<CAA-aLv6Lp-zHhnrh-SqzSeO7L8XanNjwhBQpsaP_4SqgwUHcmw@mail.gmail.com>
	<CA+OCxoyH6SNE_T+2p=4sQHHoTzsOOVuT+HEzqZMzgbKRXn_EAA@mail.gmail.com>
	<CAA-aLv54foGwCFYgsEN=tHM=Jzf=HBdsK96X+M0AaKigXh9OTg@mail.gmail.com>
	<CA+OCxoxN3D+tojy+67LNc702oP2JrK9035HtSROYeJErb6EXqw@mail.gmail.com>

On Tue, 23 Apr 2024 at 13:50, Dave Page <[email protected]> wrote:

>
>
> On Tue, 23 Apr 2024 at 12:03, Thom Brown <[email protected]> wrote:
>
>>
>>> You've been able to do the "Select and run" thing for years. If you
>>> select text in the editor and hit the execute button, only the selected
>>> text is sent to the server. If nothing is selected, the entire string is
>>> sent. This feature will complement that for convenience, but for safety
>>> will have a separate button/shortcut.
>>>
>>
>> Oh, I clearly don't use PgAdmin enough to know this already.
>>
>
> Boo!
>
>
>>
>> I still find the proposal somewhat unintuitive, but the foot-gun
>> safeguards that have been suggested sound like any pedal injuries will
>> solely be the fault of the user.
>>
>> I would want to see it tested in a diverse range of scenarios though,
>> which will require some imagination given what users will no doubt try to
>> use it on.
>>
>
> Yes, I have made that very clear to the team. Suggestions for test
> scenarios are welcome of course - a good way to experiment might be to see
> how the current version of pgAdmin (which uses the new CodeMirror code)
> manages to mess up syntax highlighting of anything weird.
>

I guess here's a few to try out:

-- Put the cursor on every relation name, and every SELECT, DELETE and
INSERT
WITH deleted_rows AS (
  DELETE FROM mytable WHERE id IN (
    -- Does this run on its own?
    SELECT id FROM mytable
  )
  RETURNING id, content
),
move_rows AS (
  INSERT INTO newtable
  -- Does this SELECT run on its own, or does it backtrack to the INSERT?
  SELECT id, content
  FROM deleted_rows
),
combined_result AS(
  SELECT tableoid::regclass, id, content
  FROM mytable
  UNION ALL
  -- Does this SELECT get run on its own?
  SELECT tableoid::regclass, id, content
  FROM newtable
)
-- Does this SELECT get run on its own?
SELECT id, content
INTO backuptable
FROM combined_result;


SELECT id, content
FROM (
  /*
    We are just performing:
    SELECT id, content
    FROM newtable;
    ... at 2 levels
    Does that commented query above highlight?

    Does each level of the query and nested queries run correctly?
  */
  SELECT id, content, 'dummy1'
  FROM (
     SELECT id, content, 'dummmy1', 'dummy2'
     FROM newtable
  )
);


DO LANGUAGE plpgsql $SELECT$
DECLARE
  myrec RECORD;
  -- Does either SELECT in the cursor try to run when under PgAdmin's
cursor?
  -- Is there any backtracking when selecting the 2nd one?
  mycur CURSOR FOR SELECT 1 FROM (SELECT (VALUES (1)));
BEGIN
  SELECT INTO STRICT myrec FROM (
    -- Does selecting the following SELECT correctly run without going
    -- into the SELECT INTO?
    SELECT
 -- Can you run the query that appears in the value?
      $$SELECT * FROM mytable$$ AS query,

 -- What happens when you select either of these SELECTs?
      'SELECT' AS "SELECT",

 -- And what happens on each one of these 4 DELETEs
      $DELETE$DELETE$DELETE$ AS "DELETE"
  );
END
$SELECT$;

None of this renders incorrectly in PgAdmin though.

Thom


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Regarding feature #6841
  In-Reply-To: <CAA-aLv4nVeTmGPTtEi15y+Pn-usOoY7KPu594QzQtF9ikG0yYg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox