mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
Review our Postgres catalog usage for default values.
The pg_catalog.pg_attribute column adsrc is populated only once, and then not maintained by the server. The function pg_get_expr(adbin, adrelid) is what to use and has been here since release 8.0, so that's what pgloader should be using. Fixed #1934.
This commit is contained in:
parent
26cc9ca79f
commit
8a13c02561
@ -7,8 +7,8 @@ with seqattr as
|
|||||||
(
|
(
|
||||||
select adrelid,
|
select adrelid,
|
||||||
adnum,
|
adnum,
|
||||||
adsrc,
|
pg_get_expr(d.adbin, d.adrelid) as adsrc,
|
||||||
case when adsrc ~~ 'nextval'
|
case when pg_get_expr(d.adbin, d.adrelid) ~~ 'nextval'
|
||||||
then substring(pg_get_expr(d.adbin, d.adrelid)
|
then substring(pg_get_expr(d.adbin, d.adrelid)
|
||||||
from '''([^'']+)'''
|
from '''([^'']+)'''
|
||||||
)
|
)
|
||||||
@ -23,7 +23,9 @@ with seqattr as
|
|||||||
else null
|
else null
|
||||||
end as typmod,
|
end as typmod,
|
||||||
attnotnull,
|
attnotnull,
|
||||||
case when atthasdef then def.adsrc end as default,
|
case when atthasdef
|
||||||
|
then pg_get_expr(def.adbin, def.adrelid)
|
||||||
|
end as default ,
|
||||||
case when s.seqname is not null then 'auto_increment' end as extra
|
case when s.seqname is not null then 'auto_increment' end as extra
|
||||||
from pg_class c
|
from pg_class c
|
||||||
join pg_namespace n on n.oid = c.relnamespace
|
join pg_namespace n on n.oid = c.relnamespace
|
||||||
|
Loading…
Reference in New Issue
Block a user