How does mysql interpret tabs?

Discussion of non-phpBB related topics with other phpBB.com users.
Forum rules
General Discussion is a bonus forum for discussion of non-phpBB related topics with other phpBB.com users. All site rules apply.
Post Reply
User avatar
pjdm
Registered User
Posts: 35
Joined: Thu Aug 07, 2008 9:27 pm
Location: Calgary eh?
Name: Paul Miller
Contact:

How does mysql interpret tabs?

Post by pjdm »

I moved hosts recently. I activated debugging in phpbb 3.0.14 and occasionally receive an error. When I looked at the source of the problem it appeared that there is no space in this code but obviously it is tested phpbb code so how does mysql interpret tabs? does it insert a space before the WHERE statement below?

Here is the code from 3.0.14 cron.php

Code: Select all

function unlock_cron()
{
	global $db;

	$sql = 'UPDATE ' . CONFIG_TABLE . "
		SET config_value = '0'
		WHERE config_name = 'cron_lock' AND config_value = '" . $db->sql_escape(CRON_ID) . "'";
	$db->sql_query($sql);
}
There is no space between the SET and WHERE when this is executed on my server. I get this error.
2017-01-03 19_07_30.png
2017-01-03 19_07_30.png (4.65 KiB) Viewed 3126 times
I don't believe this appears when debugging is turned off and it is random because of the cron timing. When I look at all other SET WHERE structures in phpbb there is always a space added in the code before the WHERE. So, what is wrong with this code? It has been used for years so I'm missing something or was this an error not previously detected?

User avatar
david63
Registered User
Posts: 17755
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: How does mysql interpret tabs?

Post by david63 »

mySql does not interpret tabs/spaces or anything else - that is done by PHP.

The error you are getting is just waht it says - your server cannot be accessed. You will need to speak to your hosts about that.

User avatar
pierredu
Registered User
Posts: 1086
Joined: Thu Nov 01, 2012 8:04 am
Location: Paris (France)

Re: How does mysql interpret tabs?

Post by pierredu »

CR and LF are treated as white space.

User avatar
pjdm
Registered User
Posts: 35
Joined: Thu Aug 07, 2008 9:27 pm
Location: Calgary eh?
Name: Paul Miller
Contact:

Re: How does mysql interpret tabs?

Post by pjdm »

That instruction was sent as an SQL instruction. It was already parsed by PHP and there is no space between the SET and WHERE so it will fail on the SQL instruction as it appears above correct?

edit: the above statement works as shown--I tested on a server. I will go further to see where the problem lies at the host. Thanks. I always thought mysql needed spaces and apparently not.

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26132
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: How does mysql interpret tabs?

Post by Paul »

There is a space in that query
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

User avatar
pjdm
Registered User
Posts: 35
Joined: Thu Aug 07, 2008 9:27 pm
Location: Calgary eh?
Name: Paul Miller
Contact:

Re: How does mysql interpret tabs?

Post by pjdm »

paul, I attach a shot from notepad++ with the code and all chars visible. There is no space after the '0' and just tabs before WHERE. I don't see why you think there is a space. I also just ran a copy of that code without a space and it worked on a test server as a mysql statement. It works with no space and I must have another server issue causing the problem but I thought it was interesting that this syntax never got highlighted anywhere.
Attachments
2017-01-07 14_08_58.png
2017-01-07 14_08_58.png (6.01 KiB) Viewed 3013 times

User avatar
Steve
Registered User
Posts: 1092
Joined: Tue Apr 07, 2009 7:48 pm
Location: UK ,up north!!
Name: Steven Clark
Contact:

Re: How does mysql interpret tabs?

Post by Steve »

Try encoding your notepad to utf-8.

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10383
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: How does mysql interpret tabs?

Post by Noxwizard »

The error doesn't say that there's a problem in the query. It's saying that your MySQL connection was already timed out when it tried to run that query.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

User avatar
Steve
Registered User
Posts: 1092
Joined: Tue Apr 07, 2009 7:48 pm
Location: UK ,up north!!
Name: Steven Clark
Contact:

Re: How does mysql interpret tabs?

Post by Steve »

Noxwizard wrote:
Sat Jan 07, 2017 10:09 pm
The error doesn't say that there's a problem in the query. It's saying that your MySQL connection was already timed out when it tried to run that query.
Your are correct, MySQL dump(sql transactions) is needed, OP purge your forum cache and keep trying local on a test server.

User avatar
AmigoJack
Registered User
Posts: 5715
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: How does mysql interpret tabs?

Post by AmigoJack »

Welcome to the internet. One basic thing you need to understand is: your internet browser always displays an interpretation of each website document: if the document contains tab characters or multiple space characters those displayed as one space character only. Proof:
  1. This is interpreted content with > < 5 spaces and > < 2 tabs being interpreted.
  2. Code: Select all

    This is UNinterpreted content with >     < 5 spaces and >		< 2 tabs being interpreted.
Go look into the source code (mostly available per CTRL+U) and see that both texts have their multiple spaces and tab characters.



As others pointed out already: it has nothing to do with the error message, tho. Answering your initial question: MySQL interprets tab characters like most software context wise: if used in a literal, it's just a character; if used in a command, it's a whitespace just like the space character.

Post Reply

Return to “General Discussion”