Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Decimal Values with Incorrect Byte Order on s390x Architecture #5308

Copy link
Copy link

Description

@farukterzioglu
Issue body actions

Issue Description:

Decimal values retrieved from a PostgreSQL database exhibit incorrect byte order when the application runs on an s390x machine using .NET 6.0. On x64/x86 machines, the application functions correctly. The issue is observed with Npgsql version 7.0.6.

Reproducibility:

The issue can be easily reproduced using the provided Dockerfile, which includes the source code for the application. The Dockerfile creates a simple .NET application that sends a basic request to the database, highlighting the incorrect byte order for decimal values on s390x.

Steps to Reproduce:

Build and run the provided Dockerfile on an s390x machine.
Observe the returned decimal values from the database using the specified query.

Expected Behavior:

The decimal values retrieved from the database should have consistent byte order across different architectures.

Actual Behavior:

On s390x, decimal values are returned with an inverted byte order when using Npgsql version 7.0.6, while the same application running on x64/x86 machines behaves as expected.

Environment Details:

.NET Version: 6.0
PostgreSQL Version: 12
Npgsql Version: 7.0.6
Operating System: Ubuntu 22.04.3

Dockerfile:

ARG BUILDPLATFORM=linux
FROM --platform=$BUILDPLATFORM alpine:3.17.4 AS builder

RUN apk add dotnet6-sdk

WORKDIR /app

RUN echo -e "\
<Project Sdk=\"Microsoft.NET.Sdk\">\n\

  <PropertyGroup>\n\
    <OutputType>Exe</OutputType>\n\
    <TargetFramework>net6.0</TargetFramework>\n\
    <ImplicitUsings>enable</ImplicitUsings>\n\
    <Nullable>enable</Nullable>\n\
  </PropertyGroup>\n\

  <ItemGroup>\n\
    <PackageReference Include=\"Npgsql\" Version=\"7.0.6\" />\n\
  </ItemGroup>\n\

</Project>\n\
" > ./NpgSqlTest.csproj

RUN dotnet restore

RUN echo -e "\
using System; \n\
using Npgsql; \n\

string connectionString = \"Username=postgres;Password='postgres';Server=172.17.0.1;Database=postgres;\"; \n\

using NpgsqlConnection connection = new(connectionString); \n\
connection.Open(); \n\

using NpgsqlCommand command = new(\"SELECT 1::decimal\", connection); \n\
using NpgsqlDataReader reader = command.ExecuteReader(); \n\

reader.Read(); \n\
Console.Write(reader[0]); \n\
" > ./Program.cs

RUN dotnet build -c Release -o out

WORKDIR /app/out

ENTRYPOINT ["dotnet", "NpgSqlTest.dll"]

to build and run it;

docker build -t npgsqltest .
docker run --rm npgsqltest

On a x64/x86 machine it prints 1 as expected. But on a s390x it prints 4294967296.

A query as SELECT 1::int works fine on both architectures.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.