Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:46:29+00:00 2026-06-11T14:46:29+00:00

I am new to SO and postgres so please excuse my ignorance. Attempting to

  • 0

I am new to SO and postgres so please excuse my ignorance. Attempting to get the cluster for a graph in postgres using a solution similar to the one in this post Find cluster given node in PostgreSQL

the only difference is my id is a UUID and I am using varchar(255) to store this id

when i try to run the query I get the following error (but not sure how to cast):

ERROR: recursive query "search_graph" column 1 has type character varying(255)[] in non-recursive term but type character varying[] overall

SQL state: 42804
Hint: Cast the output of the non-recursive term to the correct type.
Character: 81

my code (basically same as previous post):

WITH RECURSIVE search_graph(path, last_profile1, last_profile2) AS (
SELECT ARRAY[id], id, id
FROM node WHERE id = '408d6b12-d03e-42c2-a2a7-066b3c060a0b'
UNION ALL
SELECT sg.path || m.toid || m.fromid, m.fromid, m.toid
FROM search_graph sg
JOIN rel m
ON (m.fromid = sg.last_profile2 AND NOT sg.path @> ARRAY[m.toid]) 
   OR (m.toid = sg.last_profile1 AND NOT sg.path @> ARRAY[m.fromid])
)

 SELECT DISTINCT unnest(path) FROM search_graph;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:46:30+00:00Added an answer on June 11, 2026 at 2:46 pm

    Try casting the SELECT lists in the recursive and non-recursive terms to varchar.

    WITH RECURSIVE search_graph(path, last_profile1, last_profile2) AS (
        SELECT ARRAY[id]::varchar[], id::varchar, id::varchar
        FROM node WHERE id = '408d6b12-d03e-42c2-a2a7-066b3c060a0b'
      UNION ALL
        SELECT (sg.path || m.toid || m.fromid)::varchar[], m.fromid::varchar, m.toid::varchar
        FROM search_graph sg
        JOIN rel m
        ON (m.fromid = sg.last_profile2 AND NOT sg.path @> ARRAY[m.toid]) 
           OR (m.toid = sg.last_profile1 AND NOT sg.path @> ARRAY[m.fromid])
    )
    SELECT DISTINCT unnest(path) FROM search_graph;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem creating new records in postgres database. Using Heroku Cedar stack and Rails 3.2.
We are using hibernate, postgres 8.3x Our entities are many to one mapped with
I am very new to postgres. I got this error when try to run
I'm new to postgres, so please take it easy on me. I'm trying to
Im new to Postgres and I dont know how to translate this MySQL query
I'm using JPA with a postgres DBMS and I'm trying to create a new
For a new project I'm trying to run postgres locally. Mac Lion has Postgres
I'm new to the Oracle Platform (having primarily used MySQL, with a little Postgres
new on ruby and using windows xp and rails 3, i want to send
New to PHP and MySQL, have heard amazing things about this website from Leo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.