Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG NOTIFY not accessible #38986

Closed
gduls opened this issue Sep 24, 2020 · 7 comments
Closed

PG NOTIFY not accessible #38986

gduls opened this issue Sep 24, 2020 · 7 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Feedback Waiting on the submitter for answers

Comments

@gduls
Copy link

gduls commented Sep 24, 2020

Describe the bug
Unable to access layer actions using pg_notify.
This may be an addendum to issue #25917

How to Reproduce

  1. Create project with PostgreSQL/PostGIS connection.
  2. Add a layer from said connection.
  3. Attempt to either refresh said layer or perform a layer action using pg_notify.
  4. Nothing happens.

QGIS and OS versions

QGIS version 3.14.16-Pi QGIS code revision a235a14
Compiled against Qt 5.12.8 Running against Qt 5.12.8
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.0-CAPI-1.13.1 Running against GEOS 3.8.0-CAPI-1.13.1
Compiled against SQLite 3.31.1 Running against SQLite 3.31.1
PostgreSQL Client Version 12.4 (Ubuntu 12.4-0ubuntu0.20.04.1) SpatiaLite Version 4.3.0a
QWT Version 6.1.4 QScintilla2 Version 2.11.2
Compiled against PROJ 6.3.1 Running against PROJ Rel. 6.3.1, February 10th, 2020
OS Version Linux Mint 20
Active python plugins DataUpdater; BRLSManager; PinSearch; addressfinder; latlontools; LayerUpdateManager; drafting_table; VicinityRestore; qgsAzimuth; nc_contour_download; processing; db_manager

Additional context
-This also occurs for a clean install on the same system.
-This also affects the most recent Windows version (as of this writing, 2020-09-23) with a clean install.
-It seems it could be a powerful feature, but it simply does not work.
-It may be confusing for new users to find tutorials on how to implement this feature, only to find it to be non-functional; despite the clearly displayed options to utilize it in both the layer rendering menu and the layer action menu.

@gduls gduls added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 24, 2020
@gioman gioman added the Data Provider Related to specific vector, raster or mesh data providers label Sep 24, 2020
@elpaso
Copy link
Contributor

elpaso commented Sep 24, 2020

I've just tested both actions and generic notify on current master/linux with PG 10.14 with no issues.

@elpaso
Copy link
Contributor

elpaso commented Sep 24, 2020

@gduls about the documentation issue, can you please file a separate ticket on https://github.com/qgis/QGIS-Documentation/ ?

@gioman
Copy link
Contributor

gioman commented Sep 24, 2020

I've just tested both actions and generic notify on current master/linux with PG 10.14 with no issues.

@elpaso so can we close this? Is this just a documentation issue?

@gioman gioman added the Feedback Waiting on the submitter for answers label Sep 24, 2020
@elpaso
Copy link
Contributor

elpaso commented Sep 24, 2020

I have no idea: I cannot reproduce, the OP said that:

-It may be confusing for new users to find tutorials on how to implement this feature

so maybe we have a documentation issue.

@gduls
Copy link
Author

gduls commented Sep 24, 2020

@elpaso I can file a separate ticket for documentation, as this feature does not seem to be well documented (same with notify/refresh). Let me test this, once again, and be more explicit about what I am trying.

@gduls
Copy link
Author

gduls commented Sep 24, 2020

Additional Data to reproduce

  1. Created new user profile and new project in EPSG:4326
  2. Added connection to newly created postgis database named 'test2' and added data via
    SET standard_conforming_strings = OFF; DROP TABLE IF EXISTS "public"."test_point" CASCADE; DELETE FROM geometry_columns WHERE f_table_name = 'test_point' AND f_table_schema = 'public'; BEGIN; CREATE TABLE "public"."test_point" ( "ogc_fid" SERIAL, CONSTRAINT "test_point_pk" PRIMARY KEY ("ogc_fid") ); SELECT AddGeometryColumn('public','test_point','wkb_geometry',4326,'POINT',2); CREATE INDEX "test_point_wkb_geometry_geom_idx" ON "public"."test_point" USING GIST ("wkb_geometry"); ALTER TABLE "public"."test_point" ADD COLUMN "name" VARCHAR(10); INSERT INTO "public"."test_point" ("wkb_geometry" , "name") VALUES ('0101000020E6100000DEDDDDDDDDDDE3BF686666666666CE3F', 'test_point'); COMMIT;
  3. Added an action (please see attached screenshot for details)
  4. Tried to trigger action by the following methods:
    --psql shell
    test2=# notify qgis, 'hello';
    and
    test2=# BEGIN;
    test2=# NOTIFY qgis, 'hello;
    test2=# COMMIT;

Lastly, tried by using trigger defined as follows:
`BEGIN;
CREATE FUNCTION public.notify_qgis() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN NOTIFY qgis, 'hello';
RETURN NULL;
END;
$$;

CREATE TRIGGER notify_qgis_edit
AFTER INSERT OR UPDATE OR DELETE ON public.test_point
FOR EACH STATEMENT EXECUTE PROCEDURE public.notify_qgis();

COMMIT;`

Nothing works.

Is it possible this is a postgresql version issue? I was also unable to use pg_notify on a windows machine running postgresql version 12 64-bit, i think it was. And the version I am using for this case now is from a raspberry pi running the following:
PostgreSQL 11.7 (Raspbian 11.7-0+deb10u1) on arm-unknown-linux-gnueabihf, compiled by gcc (Raspbian 8.3.0-6+rpi1) 8.3.0, 32-bit

And POSTGIS version:
POSTGIS="2.5.1 r17027" [EXTENSION] PGSQL="110" GEOS="3.7.1-CAPI-1.11.1 27a5e771" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.0, released 2018/12/14" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.3.1" RASTER

Am I missing some critical setting that needs to be enabled? Must the connection be SSL enabled? I am not sure what I am doing incorrectly here.
Below is a screenshot of the action created for the layer.
action_image

@gduls
Copy link
Author

gduls commented Sep 24, 2020

It seems the connection must be SSL enabled. I did not see this in the docs for pg_notify or qgis, but it makes sense, in retrospect. Thank you for your time! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Feedback Waiting on the submitter for answers
Projects
None yet
Development

No branches or pull requests

3 participants