Unterminated dollar quote while create PostgreSQL function with SQL-Editor
See original GitHub issueSystem information:
- Windows 10 Pro x64 Build 17763
- DBeaver Version 6.2.3.201910211155
- No additional extensions
Connection specification:
- PostgreSQL 10
- org.postgresql.Driver
- No tunnels or proxies
Describe the problem you’re observing:
Executing a loaded script in SQL-Editor with a couple of statements for creating a new schema.
In DBeaver Version 6.2.2 works fine, in 6.2.3 throws error:
SQL-Error [42601]: Unterminated dollar quote started at position 121 in SQL CREATE OR REPLACE FUNCTION change_logging_trigger() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER AS $$ BEGIN ........
Steps to reproduce, if exist:
Create a function and try different ...AS $xxxx$
variants.
DROP SCHEMA IF EXISTS logging CASCADE;
CREATE SCHEMA logging;
SET search_path = "logging";
CREATE TABLE t_history (
id serial,
datetime timestamp DEFAULT now(),
schemaname text,
tablename text,
operation text,
modifier text DEFAULT current_user,
new_val json,
old_val json,
CONSTRAINT t_history_pk PRIMARY KEY (id)
);
CREATE INDEX t_history_datetime_idx ON logging.t_history (datetime);
COMMENT ON TABLE t_history IS 'A history for all actions on triggered actions!';
CREATE OR REPLACE FUNCTION change_logging_trigger()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
BEGIN
if TG_OP = 'INSERT' THEN
INSERT INTO logging.t_history (schemaname, tablename, operation, new_val)
VALUES (TG_TABLE_SCHEMA, TG_RELNAME, TG_OP, row_to_json(NEW));
RETURN NEW;
ELSIF TG_OP = 'UPDATE' THEN
INSERT INTO logging.t_history (schemaname, tablename, operation, new_val, old_val)
VALUES (TG_TABLE_SCHEMA, TG_RELNAME, TG_OP, row_to_json(NEW), row_to_json(OLD));
RETURN NEW;
ELSIF TG_OP = 'DELETE' THEN
INSERT INTO logging.t_history (schemaname, tablename, operation, old_val)
VALUES (TG_TABLE_SCHEMA, TG_RELNAME, TG_OP, row_to_json(OLD));
RETURN OLD;
END IF;
END;
$$;
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Unterminated dollar-quoted string creating PostgreSQL function
The issue is not with the $$ quoting: create or replace function test() returns void as $$ begin prepare plan as select 1;...
Read more >257363 – plpgsql: unterminated dollar-quoted string at or near ...
this happens because NetBeans' SQL runner ignores the '$$' quotation mark and splits statement at nearest ';', which is "dummy_result varchar;" ...
Read more >Stored Procedures on Amazon Redshift: unterminated dollar ...
Stored Procedures on Amazon Redshift: unterminated dollar-quoted string at or ... when I execute CREATE PROCEDURE command on SQL Workbench/J SQL editor.
Read more >[Solved]-Unterminated dollar quote-postgresql
DO $$ DECLARE BEGIN IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'categories')) THEN CREATE TABLE IF NOT EXISTS categories (...
Read more >Error: Unterminated dollar quote started at position <> in SQL ...
When I execute the below postgres function in pgadmin, ... throws the error: Unterminated dollar quote started at position 274 in SQL CREATE...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This bug is the reason I reverted to 6.2.2. All my code uses $$. waiting for a fixed version.
for this issue, in dbeaver 6.2.5 i could solve the issue by use $$ with tag name for functions create. e.g $name_tag$
but, when i download new version of dbeaver (6.3.1) this issue happen again and i cant workaround by add nametag between dollar.
so, i downgrade the version from 6.3.1 to 6.2.5 cause i cant fix this issue in 6.3.1 version