babelfish_extensions icon indicating copy to clipboard operation
babelfish_extensions copied to clipboard

[Bug]: Select into statement returns always -1 updated rows

Open stephanep-croesus opened this issue 1 year ago • 3 comments

What happened?

When I execute "int SqlCommand.ExecuteNonQuery()", this function return always -1 on babelfish when the command is a "select into" statement.

Ref: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand.executenonquery?view=net-8.0-pp

We see the same error in DBeaver : image

On sql Server, the same request returns 1 affected rows

FYI: Babelfish works good with these statements : create table #tmp2 (c1 int not null) insert into #tmp2 (c1) values(1) --updated rows = 1 : good update #tmp2 set c1 = 2 --updated rows = 1 : good delete #tmp2 --updated rows = 1 : good delete #tmp2 --updated rows =0 : good

Version

BABEL_4_X_DEV (Default)

Extension

babelfishpg_tsql (Default)

Which flavor of Linux are you using when you see the bug?

Amazon Linux

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct.

stephanep-croesus avatar Dec 04 '24 14:12 stephanep-croesus

I cannot reproduce this issue. On 4.3.0 as well as on earlier versions it works correctly for me:

1> select 1 as c1 into #tmp
2> select @@rowcount
3> go
rowcount
-----------
          1

(1 rows affected)

robverschoor avatar Dec 04 '24 14:12 robverschoor

I got the good value if I do "select @@rowcount" after the select into statement. I rephrased my bug description, it's about the function "int ExecuteNonQuery()" my problem.

stephanep-croesus avatar Dec 04 '24 15:12 stephanep-croesus

I am able to reproduce this

1> SELECT * INTO #t FROM generate_series(1,10)
2> GO
1>            <-- there should have been (10 rows affected) before this

tanscorpio7 avatar Mar 09 '25 14:03 tanscorpio7