Re: Regarding feature #6841

Поиск
Список
Период
Сортировка
От Aditya Toshniwal
Тема Re: Regarding feature #6841
Дата
Msg-id CAM9w-_k2SguFM2n09BM5KZLJyb7XZTnwc1mCFKOhNA6bCCcbpw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Regarding feature #6841  (Thom Brown <thom@linux.com>)
Список pgadmin-hackers
Hi Thom,

On Thu, Apr 18, 2024 at 8:26 PM Thom Brown <thom@linux.com> wrote:
On Thu, Apr 18, 2024, 15:26 Anil Sahoo <anil.sahoo@enterprisedb.com> 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.
There is a requirement by many users to execute a query instead of the current execute script which essentially executes all the code in the editor if you don't have selection. The behaviour requested was to detect the SQL query based on position of the query and execute that - just like how DBeaver or many other SQL editors do.

Regards

Thom




--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Sr. Software Architect | enterprisedb.com
"Don't Complain about Heat, Plant a TREE"

В списке pgadmin-hackers по дате отправления:

Предыдущее
От: Aditya Toshniwal
Дата:
Сообщение: Re: Regarding feature #6841
Следующее
От: Dave Page
Дата:
Сообщение: Re: Regarding feature #6841