Skip to content

Not including the key in the SELECT results in weird behavior #26

@gkobluk

Description

@gkobluk

I have this FOREIGN table:

CREATE FOREIGN TABLE global.t_shared (
    key text,
    value text
)
SERVER cypex_etcd
OPTIONS (rowid_column 'key');

If I SELECT:

SELECT *
FROM global.t_shared
WHERE key = '/gather/78';

Result:

-[ RECORD 1 ]------------------------------------------------------------------
key   | /gather/78
value | {"host_id": 75, "host_url": "postgres://pg-eu-01:5432/db",
          "gather_id": 78, "host_name": "pg-eu-01",
          "gather_name": "collect_stats", "gather_debug": true,
          "gather_purge": true, "gather_storage": "local",
          "gather_wanted_status": "planned"}

This works well too:

SELECT key, value
FROM global.t_shared
WHERE key = '/gather/78';

Result:

-[ RECORD 1 ]------------------------------------------------------------------
key   | /gather/78
value | {"host_id": 75, "host_url": "postgres://pg-eu-01:5432/db",
          "gather_id": 78, "host_name": "pg-eu-01",
          "gather_name": "collect_stats", "gather_debug": true,
          "gather_purge": true, "gather_storage": "local",
          "gather_wanted_status": "planned"}

But selecting only value (returns 0 rows)

SELECT value
FROM global.t_shared
WHERE key = '/gather/78';

Result:

(0 rows)

UPDATE presents the same behavior:

cypex=# update global.t_shared set key=key, value = value::jsonb || jsonb_build_object('gather_status', 'active') where key = '/gather/84';
UPDATE 1
cypex=# update global.t_shared set value = value::jsonb || jsonb_build_object('gather_status', 'active') where key = '/gather/84';
UPDATE 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions