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

分表的情况下会找不到ON CONFLICT(key) #2

Open
Snorlaxa opened this issue Mar 2, 2023 · 1 comment
Open

分表的情况下会找不到ON CONFLICT(key) #2

Snorlaxa opened this issue Mar 2, 2023 · 1 comment

Comments

@Snorlaxa
Copy link

Snorlaxa commented Mar 2, 2023

Postgresql采用以下sql查找ON CONFLICT(key),在分表的情况下会找不到key

select column_names from(
        select
            t.relname as table_name,
            i.relname as index_name,
            array_to_string(array_agg(a.attname), ', ') as column_names
        from
            pg_class t,
            pg_class i,
            pg_index ix,
            pg_attribute a
        where
            t.oid = ix.indrelid
            and i.oid = ix.indexrelid
            and a.attrelid = t.oid
            and a.attnum = ANY(ix.indkey)
            and t.relkind = 'r'
            and t.relname like '%'
        group by
            t.relname,
            i.relname
        order by
            t.relname,
            i.relname) as res
    where table_name = 'table_name';

查出的table_name会是子表的名称
image

@Boris-code
Copy link
Owner

Boris-code commented Mar 2, 2023

我表示不会,你这边解决了么,可以提pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants