dimitri / pgloader

Migrate to PostgreSQL in a single command!
http://pgloader.io
Other
5.45k stars 548 forks source link

Converting decimal to numerical value sometimes get truncated (sqlserver -> postgres) #1615

Open inoa-dmpassy opened 1 month ago

inoa-dmpassy commented 1 month ago
pgloader version "3.6.7~devel"
compiled with SBCL 2.1.11.debian
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourStrongPassword!"    -p 1433:1433 --name sqlserver    -d mcr.microsoft.com/mssql/server:2022-latest
docker run -d --name postgres_db -e POSTGRES_DB=postgres-e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -v postgres_data:/var/lib/postgresql/data postgres:16

Insert data into sqlserver

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[test](
    [some_field] [decimal](28, 13) NOT NULL,
)
GO

INSERT INTO [dbo].[test] ([some_field]) VALUES (-67723280.0928298500000);
LOAD DATABASE
     FROM mssql://alphatools:alphatools@localhost/sqlserver
     INTO postgres://postgres:postgres@localhost:5432/postgres

ALTER SCHEMA 'dbo' RENAME TO 'public'

including only table names like 'test' in schema 'dbo'
;
alphatoolsdmpassy@Desktop-Daniel:~/projects/pgloader$ ./build/bin/pgloader --verbose ~/projects/alphatools-main/load.load 
2024-10-11T18:51:28.010001-03:00 NOTICE Starting pgloader, log system is ready.
2024-10-11T18:51:28.010001-03:00 LOG pgloader version "3.6.70f3557"
2024-10-11T18:51:28.010001-03:00 LOG Data errors in '/tmp/pgloader/'
2024-10-11T18:51:28.010001-03:00 LOG Parsing commands from file #P"/home/dmpassy/projects/alphatools-main/load.load"
2024-10-11T18:51:28.060003-03:00 LOG Migrating from #<MSSQL-CONNECTION mssql://alphatools@localhost:1433/alphatools {100821A8F3}>
2024-10-11T18:51:28.060003-03:00 LOG Migrating into #<PGSQL-CONNECTION pgsql://postgres@localhost:5432/asset {100821B5B3}>
Max connections reached, increase value of TDS_MAX_CONN
2024-10-11T18:51:28.130005-03:00 NOTICE Prepare PostgreSQL database.
2024-10-11T18:51:28.200008-03:00 NOTICE COPY public.portfolio_asset_test with 0 rows estimated [3/4]
Max connections reached, increase value of TDS_MAX_CONN
2024-10-11T18:51:28.230010-03:00 NOTICE DONE copying public.portfolio_asset_test in 0.010s
2024-10-11T18:51:28.240010-03:00 NOTICE Completing PostgreSQL database.
2024-10-11T18:51:28.240010-03:00 NOTICE Reset sequences
2024-10-11T18:51:28.290012-03:00 LOG report summary reset
                 table name     errors       read   imported      bytes      total time       read      write
---------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
            fetch meta data          0          1          1                     0.050s    
             Create Schemas          0          0          0                     0.000s    
           Create SQL Types          0          0          0                     0.010s    
              Create tables          0          2          2                     0.020s    
             Set Table OIDs          0          1          1                     0.000s    
---------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
public.portfolio_asset_test          0          1          1     0.0 kB          0.030s     0.020s     0.010s
---------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
    COPY Threads Completion          0          4          4                     0.030s    
     Index Build Completion          0          0          0                     0.000s    
            Reset Sequences          0          0          0                     0.020s    
               Primary Keys          0          0          0                     0.000s    
        Create Foreign Keys          0          0          0                     0.000s    
            Create Triggers          0          0          0                     0.000s    
           Install Comments          0          0          0                     0.000s    
---------------------------  ---------  ---------  ---------  ---------  --------------  ---------  ---------
          Total import time          ✓          1          1     0.0 kB          0.050s