public inbox for [email protected]  
help / color / mirror / Atom feed
From: Thom Brown <[email protected]>
To: Dave Page <[email protected]>
Cc: Anil Sahoo <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: Regarding feature #6841
Date: Thu, 18 Apr 2024 16:14:16 +0100
Message-ID: <CAA-aLv55d_mdMYAU-67drnc9VhCJ421OBr4oOO8jw3KC3W4ARA@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoxMdX9Lsyugx7=_CZ3Z6K9jxHVTOBu4q=5_1cwgXsP7LQ@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>

On Thu, Apr 18, 2024, 15:37 Dave Page <[email protected]> wrote:

> Hi
>
> On Thu, 18 Apr 2024 at 15:26, Anil Sahoo <[email protected]>
> 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.
>>
>
> My main concern is that it doesn't get it wrong. Ever. Consider:
>
> DELETE FROM foo; SELECT * FROM foo;
>
> Is that one statement or two? What if it's in the middle of a pl/python3
> function:
>
> my_sql = 'DELETE FROM foo; SELECT * FROM foo;'
>
> or
>
> my_sql = """DELETE FROM foo;
> SELECT * FROM foo;
> """
>

Or, indeed, an SQL function. Would the user want the CREATE statement to be
run, or just the embedded SQL statement? I wouldn't like to guess.

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]
  Subject: Re: Regarding feature #6841
  In-Reply-To: <CAA-aLv55d_mdMYAU-67drnc9VhCJ421OBr4oOO8jw3KC3W4ARA@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