Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server Case Sensitive Input Error #3081

Closed
dulrich14 opened this issue Aug 1, 2017 · 4 comments · Fixed by #3287
Closed

SQL Server Case Sensitive Input Error #3081

dulrich14 opened this issue Aug 1, 2017 · 4 comments · Fixed by #3287
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@dulrich14
Copy link

Bug report

When running sql server input against a case sensitive instance the query errors out.

System info:

SQL Server Collation: Latin1_General_BIN (Case sensitive)
Telegraf Version: Telegraf v1.4.0
OS: Windows

Steps to reproduce:

  1. Add a connection to a case sensitive sql server
  2. Run telegraf

Expected behavior:

No Errors

Actual behavior:

2017-08-01T19:46:00Z I! Invalid column name 'Latch'.
2017-08-01T19:46:00Z I! Invalid column name 'Lock'.
2017-08-01T19:46:00Z I! Invalid column name 'Network'.
2017-08-01T19:46:00Z I! Invalid column name 'Service broker'.
2017-08-01T19:46:00Z I! Invalid column name 'Memory'.
2017-08-01T19:46:00Z I! Invalid column name 'Buffer'.
2017-08-01T19:46:00Z I! Invalid column name 'XEvent'.
2017-08-01T19:46:00Z I! Invalid column name 'Other'.
2017-08-01T19:46:00Z I! Invalid column name 'Latch'.
2017-08-01T19:46:00Z I! Invalid column name 'Lock'.
2017-08-01T19:46:00Z I! Invalid column name 'Network'.
2017-08-01T19:46:00Z I! Invalid column name 'Service broker'.
2017-08-01T19:46:00Z I! Invalid column name 'Memory'.
2017-08-01T19:46:00Z I! Invalid column name 'Buffer'.
2017-08-01T19:46:00Z I! Invalid column name 'XEvent'.
2017-08-01T19:46:00Z I! Invalid column name 'Other'.

Additional info:

Query #9 Collecting wait stats: When the categories are inserted into the temp @w tables they are all caps. When referenced later on they are regular case.

EX Inserted as: ('LATCH_EX' , 'LATCH') , ('LATCH_KP' , 'LATCH')
Then later referenced as
, [Latch] = SUM([Latch])
, [Lock] = SUM([Lock])
, [Network] = SUM([Network])

Proposal:

Change the following query

I have attached a working version of the full query since it is too long to post. I do not know how to rebuild the source to test.

SELECT
---- measurement
measurement = 'Wait time (ms)'
---- tags
, servername= REPLACE(@@ServerName, '', ':')
, type = 'Wait stats'
---- values
, [I/O] = SUM([I/O])
, [Latch] = SUM([LATCH])
, [Lock] = SUM([LOCK])
, [Network] = SUM([NETWORK])
, [Service broker] = SUM([SERVICE BROKER])
, [Memory] = SUM(MEMORY)
, [Buffer] = SUM([BUFFER])
, [CLR] = SUM([CLR])
, [SQLOS] = SUM([SQLOS])
, [XEvent] = SUM([XEVENT])
, [Other] = SUM([OTHER])
, [Total] = SUM([I/O]+[LATCH]+[LOCK]+[NETWORK]+[SERVICE BROKER]+[MEMORY]+[BUFFER]+[CLR]+[XEVENT]+[SQLOS]+[OTHER])
FROM
(
SELECT
[I/O] = ISNULL([I/O] , 0)
, [MEMORY] = ISNULL([MEMORY] , 0)
, [BUFFER] = ISNULL([BUFFER] , 0)
, [LATCH] = ISNULL([LATCH] , 0)
, [LOCK] = ISNULL([LOCK] , 0)
, [NETWORK] = ISNULL([NETWORK] , 0)
, [SERVICE BROKER] = ISNULL([SERVICE BROKER] , 0)
, [CLR] = ISNULL([CLR] , 0)
, [XEVENT] = ISNULL([XEVENT] , 0)
, [SQLOS] = ISNULL([SQLOS] , 0)
, [OTHER] = ISNULL([OTHER] , 0)
FROM @W5 as P
PIVOT
(
SUM(WaitTimeInMs)
FOR WaitCategory IN ([I/O], [LATCH], [LOCK], [NETWORK], [SERVICE BROKER], [MEMORY], [BUFFER], [CLR], [XEVENT], [SQLOS], [OTHER])
) AS PivotTable
) as T

UNION ALL

SELECT
---- measurement
measurement = 'Wait tasks'
---- tags
, server_name= REPLACE(@@ServerName, '', ':')
, type = 'Wait stats'
---- values
, [I/O] = SUM([I/O])
, [Latch] = SUM([LATCH])
, [Lock] = SUM([LOCK])
, [Network] = SUM([NETWORK])
, [Service broker] = SUM([SERVICE BROKER])
, [Memory] = SUM(MEMORY)
, [Buffer] = SUM([BUFFER])
, [CLR] = SUM([CLR])
, [SQLOS] = SUM([SQLOS])
, [XEvent] = SUM(XEVENT)
, [Other] = SUM(OTHER)
, [Total] = SUM([I/O]+[LATCH]+[LOCK]+[NETWORK]+[SERVICE BROKER]+[MEMORY]+[BUFFER]+[CLR]+[XEVENT]+[SQLOS]+[OTHER])
FROM
(
SELECT
[I/O] = ISNULL([I/O] , 0)
, [MEMORY] = ISNULL([MEMORY] , 0)
, [BUFFER] = ISNULL([BUFFER] , 0)
, [LATCH] = ISNULL([LATCH] , 0)
, [LOCK] = ISNULL([LOCK] , 0)
, [NETWORK] = ISNULL([NETWORK] , 0)
, [SERVICE BROKER] = ISNULL([SERVICE BROKER] , 0)
, [CLR] = ISNULL([CLR] , 0)
, [XEVENT] = ISNULL([XEVENT] , 0)
, [SQLOS] = ISNULL([SQLOS] , 0)
, [OTHER] = ISNULL([OTHER] , 0)
FROM @W5 as P
PIVOT
(
SUM(WaitTaskCount)
FOR WaitCategory IN ([I/O], [LATCH], [LOCK], [NETWORK], [SERVICE BROKER], [MEMORY], [BUFFER], [CLR], [XEVENT], [SQLOS], [OTHER])
) AS PivotTable
) as T;

Wait_time_stats.txt

@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Aug 1, 2017
@danielnelson
Copy link
Contributor

@dulrich14 Can you create a pull request?

@valerian1978
Copy link

Is there any pull request for that ?
I 'm facing the same issue

@danielnelson danielnelson added this to the 1.4.2 milestone Sep 23, 2017
@danielnelson
Copy link
Contributor

@valerian1978 There isn't a pr, I'll create one next week from the bug report and if you can test we try to include it in 1.4.2.

@valerian1978
Copy link

valerian1978 commented Oct 2, 2017

Thank you very much for your answer and your action.
I'm testing it, I'll put a reply in appropriate section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants