dollar quoting with flex
(Fourth try ;-)
Attached is a patch for dollar quoting in the backend and in psql (with
the new flex scanner). I'm fairly confident about the backend (because
this is mainly Tom's work adapted :-) ) but rather less so about psql -
I don't entirely understand all the odd states in psql's scanner. I'm
not sure that I have freed up memory in all the necessary cases. Nor am
I sure what the state is or should be if we end an included file in a
dollar-quoting state, nor how to handle such a situation. So, some extra
eyeballs would be appreciated.
However - it does seem to work in my simple testing.
If this is all OK, the remaining tasks would include pg_dump, docs (Jon
Jensen says he will attack these two) and some regression tests (any
volunteers?)
cheers
andrew
Attachments:
dolq.patchtext/plain; name=dolq.patchDownload+101-5
Andrew Dunstan <andrew@dunslane.net> writes:
Attached is a patch for dollar quoting in the backend and in psql (with
the new flex scanner). I'm fairly confident about the backend (because
this is mainly Tom's work adapted :-) ) but rather less so about psql -
I don't entirely understand all the odd states in psql's scanner. I'm
not sure that I have freed up memory in all the necessary cases. Nor am
I sure what the state is or should be if we end an included file in a
dollar-quoting state, nor how to handle such a situation. So, some extra
eyeballs would be appreciated.
I'll take a look soon. The psql behavior is that a new lexer is
instantiated for each include-file level, which means that quoting
states can't persist across file boundaries. This emulates the behavior
of the old handmade lexing code, and seems fairly reasonable to me.
(By definition, you weren't in a quoting state when you recognized the
\i command, and so you shouldn't be when you come out of the include
file.) We could argue about that if people want to reconsider it, but
it seems orthogonal to the dollar-quoting change to me.
regards, tom lane
Andrew Dunstan <andrew@dunslane.net> writes:
Attached is a patch for dollar quoting in the backend and in psql (with
the new flex scanner).
Applied with minor fixes.
If this is all OK, the remaining tasks would include pg_dump, docs (Jon
Jensen says he will attack these two) and some regression tests (any
volunteers?)
I think plpgsql's lexer also needs to be taught about dollar-quoting.
regards, tom lane
Tom Lane wrote:
I think plpgsql's lexer also needs to be taught about dollar-quoting.
The attached patch appears to do the trick:
floobl=# create or replace function testme() returns text language
plpgsql as $$
floobl$# begin return $foo$a'\b$bar$foo$; end;
floobl$# $$;
CREATE FUNCTION
floobl=# select testme();
testme
----------
a'\b$bar
(1 row)
floobl=#
cheers
andrew
Attachments:
dolq-plpgsql.patchtext/plain; name=dolq-plpgsql.patchDownload+45-2
Andrew Dunstan <andrew@dunslane.net> writes:
I think plpgsql's lexer also needs to be taught about dollar-quoting.
The attached patch appears to do the trick:
Applied. It needed a little more work to handle RAISE NOTICE
reasonably, but I took care of that.
regards, tom lane