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

  • Home
  • SEARCH
  • 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 6318275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:37:16+00:00 2026-05-24T15:37:16+00:00

I have strange issue with nested left-joins in postgresql… It’s hard to explain, but

  • 0

I have strange issue with nested left-joins in postgresql… It’s hard to explain, but easy to show =) here we are:

SELECT * FROM
(
    SELECT 1 as key1
) sub1
LEFT JOIN 
(
    SELECT sub3.key3, sub4.value2 FROM
    (
        SELECT 1 as key3
    ) sub3
    LEFT JOIN 
    (
        SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2
        FROM
        (
            SELECT 1 as key5
        ) sub5
        LEFT JOIN
        (
            SELECT 1 as key6, value1
            FROM
            (
                SELECT NULL::integer as value1
            ) sub7
            WHERE false
        ) sub6 ON false

    )
    sub4 ON sub4.key5=sub3.key3
)
sub2 ON sub1.key1 = sub2.key3

The result of this query:

key1;key3;value2
1;1;NULL

And this is the problem – value2 can’t be NULL because of COALESCE in sub4 (at least I think that it can’t be =))
Anyway if we’ll change

SELECT sub3.key3, sub4.value2 FROM

with

SELECT sub3.key3, value2 FROM

we will got correct result:

key1;key3;value2
1;1;1

Is there something wrong with my mind&hands? or is it a bug?

Thanks in advance!

  • 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-05-24T15:37:16+00:00Added an answer on May 24, 2026 at 3:37 pm

    I got answer from postgresql team.
    Verdict:

    This is on HEAD from today.  Clearly there's a problem.
    

    So, it was (and it is) a bug. Thanks for all, who participated in this issue! =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
Have following strange issue, have 7 lines (same classes) but after 2 lines it's
I have a strange issue with my css navigation menu. The code is here:
We have here a strange issue. We have a comments form where users can
I have some strange issue using jQuery Validation plugin. Firs of all here is
Ok so this is kind of a strange issue, but I have got two
I have a strange issue. Here is the error message: Call to undefined method
I have a strange issue going on. It may be server related, but I
I have some strange issue with isset() function in PHP. Let me show... .
I have a very strange issue, that I'm hoping someone here can help me

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.