Hi All. I've spent huge amount of time trying to solve subj error. Fortunately, I've found a workaround, but the problem itself still exists.
I created stored procedure which updates one field in one table:
When I call this stored procedure from PHP 5:
I get the following output with error:
newfixver is 249
The query to execute is exec sp_SetFixVer 162174, 249
Warning: mssql_execute() [function.mssql-execute]: message: Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services. (severity 16) in D:\DumpServer\problem2.php on line 379
Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in D:\DumpServer\problem2.php on line 379
When I copy exec sp_SetFixVer 162174, 249 to SQL Server Management Studio 2008 and execute, it runs without error and does what is expected.
There is also the following error report in SQL Server's errorlog file: (couldn't attach errorlog and SQLDump0467.txt files, will provide on demand)
The Problems table defined as follows:
Versions table definition:
There are no triggers defined for both tables.
select @@version returns:
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)
Mar 29 2009 10:11:52
Copyright (c) 1988-2008 Microsoft Corporation
Express Edition with Advanced Services (64-bit) on Windows NT 5.2 <X64> (Build 3790: Service Pack 2)
I tried many things such as: running direct UPDATE query from PHP instead of stored procedure, setting various SET option combinations for stored procedure, restarting SQL Server, running DBCC CHECKTABLE WITH ALL_ERRORMSGS on both Problems and Versions table, running UPDATE STATISTICS WITH FULL_SCAN on both tables.
After searching this forum, I finally found the workaround. I removed FK_Problems_Versions foreign key on field I'm updating and things started going right.
Today I was lucky in finding a workaround, but other day I possibly would not.
It would be helpful to know is this error is due to my mistake or due to a bug in SQL Server 2008.
I created stored procedure which updates one field in one table:
USE [dumptest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_SetFixVer]
(
@ProblemID int,
@NewFixVersionID int
)
AS
BEGIN
UPDATE [dbo].[Problems] set FixVer = @NewFixVersionID where ProblemID = @ProblemID
RETURN 0
END
GO
When I call this stored procedure from PHP 5:
include("dbopen.php");
print "newfixver is {$_POST['newfixver']}<br>";
//Debug
$qry = "exec sp_SetFixVer {$_REQUEST['prob']}, {$_POST['newfixver']}";
print "The query to execute is $qry";
$stmt = mssql_init("sp_SetFixVer");
if($stmt &&
mssql_bind($stmt, "@ProblemID", $_REQUEST['prob'], SQLINT4, false) &&
mssql_bind($stmt, "@NewFixVersionID", $_POST['newfixver'], SQLINT4, false))
{
$res = mssql_execute($stmt);
//Debug
print "The result is $res<br>";
}
include("dbclose.php");
I get the following output with error:
newfixver is 249
The query to execute is exec sp_SetFixVer 162174, 249
Warning: mssql_execute() [function.mssql-execute]: message: Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services. (severity 16) in D:\DumpServer\problem2.php on line 379
Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in D:\DumpServer\problem2.php on line 379
When I copy exec sp_SetFixVer 162174, 249 to SQL Server Management Studio 2008 and execute, it runs without error and does what is expected.
There is also the following error report in SQL Server's errorlog file: (couldn't attach errorlog and SQLDump0467.txt files, will provide on demand)
The Problems table defined as follows:
USE [dumptest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Problems](
[ProblemID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](100) NULL,
[IssueState] [tinyint] NOT NULL,
[Issue] [int] NULL,
[FixVer] [int] NULL,
[ProductID] [int] NOT NULL,
[NeedDumpDate] [datetime] NULL,
[FirstVersionID] [int] NULL,
[LastVersionID] [int] NULL,
[DumpsCount] [int] NOT NULL,
[Author] [int] NULL,
[TTRecordID] [int] NULL,
[TTLastStudyTime] [datetime] NULL,
[FixDate] [datetime] NULL,
[KlavaDetected] [tinyint] NOT NULL,
CONSTRAINT [PK_Problem] PRIMARY KEY CLUSTERED
(
[ProblemID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Problems] WITH CHECK ADD CONSTRAINT [FK_Problem_Product] FOREIGN KEY([ProductID])
REFERENCES [dbo].[Products] ([ProductID])
GO
ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problem_Product]
GO
ALTER TABLE [dbo].[Problems] WITH CHECK ADD CONSTRAINT [FK_Problems_FirstVersion] FOREIGN KEY([FirstVersionID])
REFERENCES [dbo].[Versions] ([VersionID])
GO
ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problems_FirstVersion]
GO
ALTER TABLE [dbo].[Problems] WITH CHECK ADD CONSTRAINT [FK_Problems_IssueStates] FOREIGN KEY([IssueState])
REFERENCES [dbo].[IssueStates] ([StateID])
GO
ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problems_IssueStates]
GO
ALTER TABLE [dbo].[Problems] WITH CHECK ADD CONSTRAINT [FK_Problems_LastVersion] FOREIGN KEY([LastVersionID])
REFERENCES [dbo].[Versions] ([VersionID])
GO
ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problems_LastVersion]
GO
ALTER TABLE [dbo].[Problems] WITH CHECK ADD CONSTRAINT [FK_Problems_Versions] FOREIGN KEY([FixVer])
REFERENCES [dbo].[Versions] ([VersionID])
GO
ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problems_Versions]
GO
ALTER TABLE [dbo].[Problems] ADD DEFAULT ((0)) FOR [DumpsCount]
GO
Versions table definition:
USE [dumptest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Versions](
[VersionID] [int] IDENTITY(1,1) NOT NULL,
[Major] [smallint] NOT NULL,
[Minor] [smallint] NOT NULL,
[Build] [smallint] NOT NULL,
[Compilation] [smallint] NOT NULL,
[InstCount] [int] NULL,
[DumpsCount] [int] NOT NULL,
[TTProductID] [int] NOT NULL,
[ProductID] [int] NULL,
[Hotfix] [smallint] NOT NULL,
[VersionType] [tinyint] NOT NULL,
[Product] AS (case when [Major]=(0) AND [Minor]=(0) AND [Build]=(0) AND [Compilation]=(1) then 'AVBases' else (((CONVERT([varchar],[Major],0)+'.')+CONVERT([varchar],[Minor],0))+'.')+CONVERT([varchar],[Build],0) end) PERSISTED,
[VersionString] AS (case when [VersionType]=(1) then ((((((CONVERT([varchar],[Major],0)+'.')+CONVERT([varchar],[Minor],0))+'.')+CONVERT([varchar],[Build],0))+'.')+case when [Compilation]=(-1) then 'next' when [Compilation]=(-2) then 'inprogress' else CONVERT([varchar],[Compilation],0) end)+case when [Hotfix]=(0) then '' else char([Hotfix]) end when [VersionType]=(2) then case when [Major]=(1900) then 'Unknown' else CONVERT([varchar],dateadd(second,[Hotfix],dateadd(hour,[Compilation],dateadd(day,[Build]-(1),dateadd(month,[Minor]-(1),CONVERT([varchar],[Major],0)+'0101')))),(120)) end else '' end),
CONSTRAINT [PK_Versions] PRIMARY KEY CLUSTERED
(
[VersionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 95) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Versions] ADD CONSTRAINT [DF_Versions_Major] DEFAULT ((0)) FOR [Major]
GO
ALTER TABLE [dbo].[Versions] ADD CONSTRAINT [DF_Versions_Minor] DEFAULT ((0)) FOR [Minor]
GO
ALTER TABLE [dbo].[Versions] ADD CONSTRAINT [DF_Versions_Build] DEFAULT ((0)) FOR [Build]
GO
ALTER TABLE [dbo].[Versions] ADD CONSTRAINT [DF_Versions_Compilation] DEFAULT ((0)) FOR [Compilation]
GO
ALTER TABLE [dbo].[Versions] ADD DEFAULT ((0)) FOR [DumpsCount]
GO
ALTER TABLE [dbo].[Versions] ADD DEFAULT ((0)) FOR [TTProductID]
GO
ALTER TABLE [dbo].[Versions] ADD DEFAULT ((0)) FOR [Hotfix]
GO
ALTER TABLE [dbo].[Versions] ADD DEFAULT ((1)) FOR [VersionType]
GO
There are no triggers defined for both tables.
select @@version returns:
Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)
Mar 29 2009 10:11:52
Copyright (c) 1988-2008 Microsoft Corporation
Express Edition with Advanced Services (64-bit) on Windows NT 5.2 <X64> (Build 3790: Service Pack 2)
I tried many things such as: running direct UPDATE query from PHP instead of stored procedure, setting various SET option combinations for stored procedure, restarting SQL Server, running DBCC CHECKTABLE WITH ALL_ERRORMSGS on both Problems and Versions table, running UPDATE STATISTICS WITH FULL_SCAN on both tables.
After searching this forum, I finally found the workaround. I removed FK_Problems_Versions foreign key on field I'm updating and things started going right.
Today I was lucky in finding a workaround, but other day I possibly would not.
It would be helpful to know is this error is due to my mistake or due to a bug in SQL Server 2008.