Skip to content

How can I get WKB as a hex string? #43

@marklit

Description

@marklit

I want to get the following value out as 010300000001000000d9020000715dbf6037d656c0b1a206d330b8...

D SELECT geom from table limit 1;
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                          geom                                                           │
│                                                        geometry                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ POLYGON ((-91.3471299999999 35.43899, -91.34711 35.43949, -91.3471699999999 35.44007, -91.34737 35.4408500000001, -91…  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
D select ST_AsWKB(geom) from table limit 1;
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                     st_aswkb(geom)                                                      │
│                                                        wkb_blob                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ POLYGON ((-91.3471299999999 35.43899, -91.34711 35.43949, -91.3471699999999 35.44007, -91.34737 35.4408500000001, -91…  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
D select ST_AsWKB(geom)::BIGINT from table limit 1;
Error: Conversion Error: Unimplemented type for cast (WKB_BLOB -> BIGINT)
D select geom::BIGINT from table limit 1;
Error: Conversion Error: Unimplemented type for cast (GEOMETRY -> BIGINT)
D select ST_AsWKB(geom)::TEXT from table limit 1;
100% ▕████████████████████████████████████████████████████████████▏ 
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                             CAST(st_aswkb(geom) AS VARCHAR)                                             │
│                                                         varchar                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ POLYGON ((-91.3471299999999 35.43899, -91.34711 35.43949, -91.3471699999999 35.44007, -91.34737 35.4408500000001, -91…  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
D select ST_AsText(geom) from table limit 1;
100% ▕████████████████████████████████████████████████████████████▏ 
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                     st_astext(geom)                                                     │
│                                                         varchar                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ POLYGON ((-91.3471299999999 35.43899, -91.34711 35.43949, -91.3471699999999 35.44007, -91.34737 35.4408500000001, -91…  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
D select printf('%x', ST_AsWKB(geom)) from table limit 1;
 69% ▕█████████████████████████████████████████▍                  ▏ Run Time (s): real 2.551 user 4.143314 sys 0.336847
Error: Invalid Error: invalid type specifier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions