Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:14:51+00:00 2026-06-01T13:14:51+00:00

I am using the Geospatial extension for MySQL. In the MyISAM table listings there

  • 0

I am using the Geospatial extension for MySQL. In the MyISAM table listings there is a GEOMETRY column p, and 2 float columns lat and lng. Values in p are set using UPDATE listings SET p = POINT(lat, lng);.

Problem: Now I want to set a spatial index on column p. When I tried:

ALTER TABLE listings ADD SPATIAL INDEX(p);

and also tried:

CREATE SPATIAL INDEX sp_index ON listings (p);

Both times, I get the error error : All parts of a SPATIAL index must be NOT NULL.

So (using Navicat) I tried making col p NOT NULL, but it requires a default value. What default value should I use for this? I tried using '' as the default value but it gave an error invalid default value for 'p'.

I tried setting the default value for p as POINT(0,0) but I get the error BLOB/TEXT column 'p' can't have a default value

How should I approach this problem to create the spatial index? Thanks!

Edit

After running query ALTER TABLE listings CHANGE p p POINT NOT NULL, running ADD SPATIAL INDEX(p) causes a strange error Lost connection to MySQL server during query. Other queries that does not involve creating an index works fine ie. SELECT * FROM listings

Results from SHOW CREATE TABLE listings

CREATE TABLE `listings` (
 `listing_id` int(8) NOT NULL AUTO_INCREMENT,
 `url` varchar(255) DEFAULT NULL,
 `website_city` varchar(32) DEFAULT NULL,
 `website` varchar(32) DEFAULT NULL,
 `price` int(7) DEFAULT NULL,
 `price_per_br` int(7) DEFAULT NULL,
 `bedroom` int(2) DEFAULT NULL,
 `bathroom` int(2) DEFAULT NULL,
 `fee` varchar(10) DEFAULT NULL,
 `address_1` varchar(255) DEFAULT NULL,
 `address_2` varchar(255) DEFAULT NULL,
 `city` varchar(64) DEFAULT NULL,
 `state` varchar(32) DEFAULT NULL,
 `postal` int(6) DEFAULT NULL,
 `retrival_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 `post_timestamp` timestamp NULL DEFAULT NULL,
 `lat` float(10,6) DEFAULT NULL,
 `lng` float(10,6) DEFAULT NULL,
 `p` point NOT NULL,
 `description` text,
 `img_subpath` varchar(15) DEFAULT NULL,
 `photos` text,
 `reply_email` varchar(255) DEFAULT NULL,
 `phone` varchar(16) DEFAULT NULL,
 `has_dishwasher` tinyint(1) DEFAULT NULL,
 `has_laundry` tinyint(1) DEFAULT NULL,
 `has_fireplace` tinyint(1) DEFAULT NULL,
 `has_elevator` tinyint(1) DEFAULT NULL,
 `has_balcony` tinyint(1) DEFAULT NULL,
 `has_deck` tinyint(1) DEFAULT NULL,
 `has_backyard` tinyint(1) DEFAULT NULL,
 `has_parking` tinyint(1) DEFAULT NULL,
 `has_gym` tinyint(1) DEFAULT NULL,
 `has_pool` tinyint(1) DEFAULT NULL,
 `cats_ok` tinyint(1) DEFAULT NULL,
 `dogs_ok` tinyint(1) DEFAULT NULL,
 PRIMARY KEY (`listing_id`),
 KEY `lat lng` (`lat`,`lng`,`price`,`price_per_br`,`bedroom`,`bathroom`,`post_timestamp`) USING BTREE,
 KEY `spatial` (`p`(25))
) ENGINE=MyISAM AUTO_INCREMENT=589605 DEFAULT CHARSET=latin1

I converted p to back to GEOMETRY, ran the query to add the index to p and got a new error Cannot get geometry object from data you send to the GEOMETRY field

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:14:53+00:00Added an answer on June 1, 2026 at 1:14 pm

    This page InformIT: Data Types in MySQL claims that spatial columns cannot have a DEFAULT value but I can’t locate that info in MySQL docs:

    3.2.3 Specifying Column Default Values

    For all but BLOB and TEXT types, spatial types, or columns with the AUTO_INCREMENT attribute, you can specify a DEFAULT def_value clause to indicate that …

    Testing in my 5.1 box shows the same error as yours. So the claim is probably correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using the MySQL Geospatial extension in hope of speeding up lat/lng
Using PHP, I can convert MySQL data or static table data to csv, Excel,
This question is for Mysql geospatial-extension experts. The following query doesn't the result that
Any idea of WebMaping (Displaying a GeoSpatial Map) using flex 3. I have few
I'm using MongoDB geospatial queries -- $near , geoNear , etc. -- and I'd
I'm drawing shapes using GDI+ using a list of lat/lon floats, and I need
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Is there a recommended way to make a custom query to mongodb using django

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.