Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxTBj-008xL1-U1 for pgadmin-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 14:56:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rxTBi-005mY7-H0 for pgadmin-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 14:56:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxTBi-005mXz-6F for pgadmin-hackers@lists.postgresql.org; Thu, 18 Apr 2024 14:56:34 +0000 Received: from mail-lj1-f172.google.com ([209.85.208.172]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rxTBf-003T8V-GW for pgadmin-hackers@postgresql.org; Thu, 18 Apr 2024 14:56:32 +0000 Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2db17e876abso8735101fa.1 for ; Thu, 18 Apr 2024 07:56:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713452190; x=1714056990; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=10iQYBk4leMgPxMDScy5WGq/ZHcfoOHiz1tFNllUKgQ=; b=ZjFvy41McjYNoq3HbkTDBuMcg3dAUb41bfNdmtqpc6pcrPSFR4bg7s80AZA/x1sAQM KAr7P2Y2nf4asrQCVlIIh6+cTWZwTLTXJeX8aXRpEvLy72eKVhd5VzqSX+hLbkpU5+o9 jyWUQl08MGh6no3ZjM2kA2yJVvDAwcYv+8Jibe8ERUkwloQPBdVq+kjdAsCO1XfIXm+p 3YD+y/1dVkMpjvPDmD5rZkE3ysthMW82NvqpM9kMXnzsp9fQmV7it8LwmqiNZq3XdD6s y6jEc6oPWKwLBFXK/8AfGr8WguBGSc7tEGZf5/qs7TTT+kW0tH8JdpmeDeUdEvHcpqT+ cAcA== X-Forwarded-Encrypted: i=1; AJvYcCVIjSE1WpFXFAMr830SffSFKNITh6Krr3CQfBWBKIjJ9PAhz8LSrDV3U19ULTkBp0rn9ZfnDIA89RkaarxsiO+EiHSpAjmzSaWHdVU916A= X-Gm-Message-State: AOJu0YyeubpX3aivpRDCenPj+sTt1F6jgQ/n4GtmGArLm3+mdqsDnUr5 7MbDXOw1GqhRpZ5m/Frwld2oG3Dv4WeiFBVhqjIQnMAkrvvWnYo4vB4rRLBcbXE9ZJZ8hnNWpjX uI+MF9BddAOl3poC+LM9SNMfswzw= X-Google-Smtp-Source: AGHT+IGtTkhGNn6nbyjr6lNR1T9bjGxfLIg+DhwaN37DTzV0pbbRDhHJzwL/1Gu64ZtODVUBXgHBC84iKX7xIypeTZQ= X-Received: by 2002:a2e:8807:0:b0:2da:9ebe:e35f with SMTP id x7-20020a2e8807000000b002da9ebee35fmr1644564ljh.22.1713452189100; Thu, 18 Apr 2024 07:56:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Thom Brown Date: Thu, 18 Apr 2024 15:56:17 +0100 Message-ID: Subject: Re: Regarding feature #6841 To: Anil Sahoo Cc: Dave Page , pgadmin-hackers Content-Type: multipart/alternative; boundary="000000000000123a210616602da9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000123a210616602da9 Content-Type: text/plain; charset="UTF-8" On Thu, Apr 18, 2024, 15:26 Anil Sahoo wrote: > Hi Dave, > We took help from Code Mirror, i.e Code Mirror gives the parsed SQL from > the editor through a tree called syntaxTree and by using some logic we > extracted the statements which have semicolon in it and also added some > extra logic to break the whole query on next of next line as empty or if > comments are there. > > Using all this logic we got the individual queries and checked where our > cursor is in editor and checked with the query and through this we got the > actual query at cursor position. > > For example, > > 1. if the cursor is at starting or ending position or anywhere in > between a query with semicolon or without semicolon, that can be single > line or multi line then the query gets extracted. > 2. if the cursor is at starting or ending position or anywhere in > between a comment that can be single line or multi line then the comment > gets extracted. > 3. if the cursor is at a position where the previous line has a query > then that query gets extracted. > > For the anonymous block containing multiple queries, code mirror gives the > statements differently. That is an incomplete query we can say, so the > query tool gives error. We can say some limitations are there with Code > Mirror. > > Please let me know if you have any questions on this. > I guess my first question is, what is the requirement being fulfilled here? Also, I have more experience with selecting what to run, and having it run whatever was selected. I don't see the current proposal as particularly intuitive. Having the cursor midway through a statement (or even the last line of a statement) doesn't quite feel right. What would happen in this example?... SELECT contents FROM |mytable WHERE id BETWEEN 101 AND 200 ORDER BY id ASC; Note I placed a pipe to represent the cursor before the table name. And would it make a difference if the first 3 lines were a single line? In any case, given all statements are separated by semicolons in PostgreSQL, I am resistant to the idea of supporting them without for specific features. Regards Thom --000000000000123a210616602da9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Apr 18, 2024, 15:26 Anil Sahoo <anil.sahoo@enterprisedb.com> wrote:
<= /div>
Hi Dave,
We took h= elp from Code Mirror, i.e Code Mirror gives the parsed SQL from the editor = through a tree called syntaxTree and by using some logic we extracted the s= tatements which have semicolon in it and also added some extra logic to bre= ak the whole query on next of next line as empty or if comments are there.<= /div>

Using all this logic we got the individual queries= and checked where our cursor is in editor and checked=C2=A0with the query= =C2=A0and through this we got the actual query at cursor position.

For example,=C2=A0
  1. if the cursor is at s= tarting or ending position or anywhere in between a query with semicolon or= without semicolon, that can be single line or multi line then the query ge= ts extracted.
  2. if the cursor is at starting or ending position o= r anywhere in between a comment that can be single line or multi line then = the comment gets extracted.
  3. if the cursor is at a position where th= e previous line has a query then that query gets extracted.=C2=A0
=
For the anonymous block containing multiple queries, code mirror= gives the statements differently. That is an incomplete query we can say, = so the query tool gives error. We can say some limitations are there with C= ode Mirror.

Please let me know if you have any que= stions on this.

<= /div>
I guess my first question is, what is the requiremen= t being fulfilled here?

= Also, I have more experience with selecting what to run, and having it run = whatever was selected. I don't see the current proposal as particularly= intuitive. Having the cursor midway through a statement (or even the last = line of a statement) doesn't quite feel right. What would happen in thi= s example?...

SELECT con= tents
FROM |mytable
WHERE id = BETWEEN 101 AND 200

ORDE= R BY id ASC;

Note I plac= ed a pipe to represent the cursor before the table name. And would it make = a difference if the first 3 lines were a single line?

In any case, given all statements are separat= ed by semicolons in PostgreSQL, I am resistant to the idea of supporting th= em without for specific features.

Regards

Thom


--000000000000123a210616602da9--