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 1rxSiq-008tJy-Vr for pgadmin-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 14:26:45 +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 1rxSip-005VQl-Hh for pgadmin-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 14:26:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxSip-005VQV-7P for pgadmin-hackers@lists.postgresql.org; Thu, 18 Apr 2024 14:26:43 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rxSih-001dkB-8j for pgadmin-hackers@postgresql.org; Thu, 18 Apr 2024 14:26:41 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-518e2283bd3so1354084e87.1 for ; Thu, 18 Apr 2024 07:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1713450393; x=1714055193; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lbL6OU0WC6AU0F46zVqCE6y/qK2xeiAudYp1f8gO3Mw=; b=VVUQ90yWy2kTXcE63QL+MhcQhkhso7B6TpAhO7HZ3yrImUDEOs7A49bzXfcLoBd69v dFtmv6569mUZGjf2JLtxaScA6OhXeNFXCRzXkmwuVsRpXNsjCDg+BZ0/Af4iLK0QloPO 50jJxURu3CajcSiAPriIF+yFwywSzygijCAIClkSfmSn53MIG3WS4mPZVsugvB+QjjK9 REXg5nJyXzGaWIutvhDjdVv1V0SoaMfpijiXvm2MwHnmJGPI/4i/T+X57d8DL+eLZvvA EUJl0/QAl5S7shS+uRzNt6mrXQpHwJZCPJA9OZ9O9/xnsBQ6+aQtwlc7BWvWU6vXuRVl +/nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713450393; x=1714055193; 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=lbL6OU0WC6AU0F46zVqCE6y/qK2xeiAudYp1f8gO3Mw=; b=UEbIgmzQjD/OdARBz3pdaCek0UVnh+Zwl/BvT2o/DFcu/c/0GiAK5AhMZt4GzK47Uq N0PTpaWCUME1ErjwB+OIv4IUrss7FUwcTJ5iBD2isW4dB8HC/12zcNv4mfwPxvH/+hhd y5PWZBZhIorD4iOluigEJjHZmIHqyu4nnNlvu5QyNBXoUO8aZzEac+lpPanV2YzMJ0+F vofa1NH9adWl56iHL26TEMbQkRSCb0udq9GtFiNRG9TK94BbXtqhgSj4uppcvvcQVsmg ISscZ02s6AxLKd7A08PA6WkHlM+lBIuEEF37QAgOdgi+2XsSUvuHcK1vNrazMLrUEuKy 5l5g== X-Gm-Message-State: AOJu0Yxv/M0cT0nDXPdru+jKoedxZEPolgzNJm4xJetZ1fsdOWlGD/56 1xj8aSlPFx1QYOc1IIRYiFaqVYB7cXuYM4OiGl53OyMhKgE4qzotnOTKvCxALUDy/Xd16ZwhC9D Z3jO677LDRM8QRByXfAdbjc/CYNFCJnmLetwaUcPoZIKs8Ixg0Q== X-Google-Smtp-Source: AGHT+IERt5ssjxvazl/XsUoQvgKYsYbmWu/Gg9Cus/pE+dZUVnVpRho8KERoAB4Fdsx0WtDJ08S1pRTfcZGTpWk5JU0= X-Received: by 2002:ac2:5b5b:0:b0:518:d5c4:d9b7 with SMTP id i27-20020ac25b5b000000b00518d5c4d9b7mr2032909lfp.16.1713450393430; Thu, 18 Apr 2024 07:26:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anil Sahoo Date: Thu, 18 Apr 2024 19:55:56 +0530 Message-ID: Subject: Re: Regarding feature #6841 To: Dave Page Cc: pgadmin-hackers@postgresql.org Content-Type: multipart/alternative; boundary="0000000000000aa19c06165fc2f5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000aa19c06165fc2f5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. Regards Anil -- *Anil Sahoo* Software Engineer www.enterprisedb.com Power to Postgres On Thu, Apr 18, 2024 at 2:24=E2=80=AFPM Dave Page wrote= : > Hi > > On Wed, 17 Apr 2024 at 15:08, Anil Sahoo > wrote: > >> Hi Hackers, >> >> This feature is about executing a query at the cursor position. And that >> query can be a one line or multiline. I have assigned a play icon button >> and F5 as the keyboard shortcut for the Execute Query feature, and for >> Execute Script, Playlist icon button and Alt+F5(Others),Option+F5(Mac) a= s >> keyboard shortcut. >> >> As now the query can run at cursor position, so for user convenience I a= m >> showing the current query just beside the Data Output toolbar. And on ho= ver >> of the text, it will show the whole query as a tooltip. This query text >> will be available for both Execute Script and Execute Query. >> >> I have made the UI change for the feature #6841 >> . >> >> Please provide your suggestions and feedback if these changes look okay >> to you. >> > > How is this parsing the query to figure out the correct text to send to > the server? For example, I notice you have no semi-colons on many of the > queries in your test; is it breaking on newlines? What if there's a newli= ne > (or multiple of them) in the query string? How does it cope with an > anonymous block containing multiple queries, or a pl/whatever function > definition that might contain queries within its text? Or a view definiti= on? > > -- > Dave Page > pgAdmin: https://www.pgadmin.org > PostgreSQL: https://www.postgresql.org > EDB: https://www.enterprisedb.com > > --0000000000000aa19c06165fc2f5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Dave,
We took help from Code Mirror, i.e Code Mirro= r 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 l= ine as empty or if comments are there.

Using all t= his 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 act= ual query at cursor position.

For example,=C2=A0
  1. if the cursor is at starting or ending position or anywher= e in between a query with semicolon or without semicolon, that can be singl= e line or multi line then the query gets extracted.
  2. if the curs= or 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. i= f the cursor is at a position where the previous line has a query then that= query gets extracted.=C2=A0
For the anonymous block co= ntaining multiple queries, code mirror gives the statements differently. Th= at 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.

<= div>Regards
Anil
--

<= p dir=3D"ltr" style=3D"line-height:1.2;margin-top:0pt;margin-bottom:0pt">

=

= Anil Sahoo

Software Engineer

www.enterprisedb.com

Power to Postgres

=C2=A0 =C2=A0 =C2=A0 <= /a> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <= /a>


<= /div>
O= n Thu, Apr 18, 2024 at 2:24=E2=80=AFPM Dave Page <dpage@pgadmin.org> wrote:
=
Hi

On Wed, 17 Apr 2024 at 15:08, Anil Sahoo <anil.sahoo@enter= prisedb.com> wrote:
Hi Ha= ckers,

This feature is about executing a query=C2=A0at t= he=C2=A0cursor position. And that query can be a one=C2=A0line or multiline= . I have assigned a play icon button and F5 as the keyboard shortcut for th= e Execute Query feature, and for Execute Script, Playlist icon button and A= lt+F5(Others),Option+F5(Mac) as keyboard shortcut.

As now the query can run at cursor position, so for user convenience I am = showing the current query just beside the Data=C2=A0Output toolbar. And on = hover of the text, it will show the whole query as a tooltip. This query te= xt will be available for both Execute Script and Execute Query.
<= br>
I have made the UI change for the feature #6841.= =C2=A0

Please provide your suggestions and feedbac= k if these changes look okay to you.

How is this parsing the query to figure out the correct text to send = to the server? For example, I notice you have no semi-colons=C2=A0on many o= f the queries in your test; is it breaking on newlines? What if there's= a newline (or multiple of them) in the query string? How does it cope with= an anonymous block containing multiple queries, or a pl/whatever function = definition that might contain queries within its text? Or a view definition= ?
=C2=A0
--
--0000000000000aa19c06165fc2f5--