@@ -331,6 +331,99 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond)
331
331
}
332
332
333
333
334
+ #ifdef HAVE_SPATIAL
335
+ static int fill_spatial_ref_sys (THD *thd, TABLE_LIST *tables, COND *cond)
336
+ {
337
+ DBUG_ENTER (" fill_spatial_ref_sys" );
338
+ TABLE *table= tables->table ;
339
+ CHARSET_INFO *cs= system_charset_info;
340
+ int result= 1 ;
341
+
342
+ restore_record (table, s->default_values );
343
+
344
+ table->field [0 ]->store (-1 , FALSE ); /* SRID*/
345
+ table->field [1 ]->store (STRING_WITH_LEN (" Not defined" ), cs); /* AUTH_NAME*/
346
+ table->field [2 ]->store (-1 , FALSE ); /* AUTH_SRID*/
347
+ table->field [3 ]->store (STRING_WITH_LEN (" " ), cs);/* SRTEXT*/
348
+ if (schema_table_store_record (thd, table))
349
+ goto exit;
350
+
351
+ table->field [0 ]->store (0 , TRUE ); /* SRID*/
352
+ table->field [1 ]->store (STRING_WITH_LEN (" Cartesian plane" ), cs); /* AUTH_NAME*/
353
+ table->field [2 ]->store (0 , TRUE ); /* AUTH_SRID*/
354
+ table->field [3 ]->store (STRING_WITH_LEN (" " ), cs);/* SRTEXT*/
355
+ if (schema_table_store_record (thd, table))
356
+ goto exit;
357
+
358
+ result= 0 ;
359
+
360
+ exit:
361
+ DBUG_RETURN (result);
362
+ }
363
+
364
+
365
+ static int get_geometry_column_record (THD *thd, TABLE_LIST *tables,
366
+ TABLE *table, bool res,
367
+ LEX_STRING *db_name,
368
+ LEX_STRING *table_name)
369
+ {
370
+ CHARSET_INFO *cs= system_charset_info;
371
+ TABLE *show_table;
372
+ Field **ptr, *field;
373
+ DBUG_ENTER (" get_geometry_column_record" );
374
+
375
+ if (tables->schema_table )
376
+ goto exit;
377
+ show_table= tables->table ;
378
+ ptr= show_table->field ;
379
+ show_table->use_all_columns (); // Required for default
380
+ restore_record (show_table, s->default_values );
381
+
382
+ for (; (field= *ptr) ; ptr++)
383
+ if (field->type () == MYSQL_TYPE_GEOMETRY)
384
+ {
385
+ Field_geom *fg= (Field_geom *) field;
386
+
387
+ DEBUG_SYNC (thd, " get_schema_column" );
388
+
389
+ /* Get default row, with all NULL fields set to NULL */
390
+ restore_record (table, s->default_values );
391
+
392
+ /* F_TABLE_CATALOG*/
393
+ table->field [0 ]->store (STRING_WITH_LEN (" def" ), cs);
394
+ /* F_TABLE_SCHEMA*/
395
+ table->field [1 ]->store (db_name->str , db_name->length , cs);
396
+ /* F_TABLE_NAME*/
397
+ table->field [2 ]->store (table_name->str , table_name->length , cs);
398
+ /* G_TABLE_CATALOG*/
399
+ table->field [3 ]->store (STRING_WITH_LEN (" def" ), cs);
400
+ /* G_TABLE_SCHEMA*/
401
+ table->field [4 ]->store (db_name->str , db_name->length , cs);
402
+ /* G_TABLE_NAME*/
403
+ table->field [5 ]->store (table_name->str , table_name->length , cs);
404
+ /* G_GEOMETRY_COLUMN*/
405
+ table->field [6 ]->store (field->field_name , strlen (field->field_name ), cs);
406
+ /* STORAGE_TYPE*/
407
+ table->field [7 ]->store (1LL , TRUE ); /* Always 1 (binary implementation)*/
408
+ /* GEOMETRY_TYPE*/
409
+ table->field [8 ]->store ((longlong) (fg->get_geometry_type ()), TRUE );
410
+ /* COORD_DIMENSION*/
411
+ table->field [9 ]->store (2LL , TRUE );
412
+ /* MAX_PPR*/
413
+ table->field [10 ]->set_null ();
414
+ /* SRID*/
415
+ table->field [11 ]->store ((longlong) (fg->get_srid ()), TRUE );
416
+
417
+ if (schema_table_store_record (thd, table))
418
+ DBUG_RETURN (1 );
419
+ }
420
+
421
+ exit:
422
+ DBUG_RETURN (0 );
423
+ }
424
+ #endif /* HAVE_SPATIAL*/
425
+
426
+
334
427
/* **************************************************************************
335
428
** List all Authors.
336
429
** If you can update it, you get to be in it :)
@@ -8747,6 +8840,39 @@ ST_FIELD_INFO show_explain_fields_info[]=
8747
8840
};
8748
8841
8749
8842
8843
+ #ifdef HAVE_SPATIAL
8844
+ ST_FIELD_INFO geometry_columns_fields_info[]=
8845
+ {
8846
+ {" F_TABLE_CATALOG" , FN_REFLEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8847
+ {" F_TABLE_SCHEMA" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8848
+ {" F_TABLE_NAME" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8849
+ {" F_GEOMETRY_COLUMN" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , " Field" ,
8850
+ OPEN_FRM_ONLY},
8851
+ {" G_TABLE_CATALOG" , FN_REFLEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8852
+ {" G_TABLE_SCHEMA" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8853
+ {" G_TABLE_NAME" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , OPEN_FRM_ONLY},
8854
+ {" G_GEOMETRY_COLUMN" , NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0 , 0 , " Field" ,
8855
+ OPEN_FRM_ONLY},
8856
+ {" STORAGE_TYPE" , 2 , MYSQL_TYPE_TINY, 0 , 0 , 0 , OPEN_FRM_ONLY},
8857
+ {" GEOMETRY_TYPE" , 7 , MYSQL_TYPE_LONG, 0 , 0 , 0 , OPEN_FRM_ONLY},
8858
+ {" COORD_DIMENSION" , 2 , MYSQL_TYPE_TINY, 0 , 0 , 0 , OPEN_FRM_ONLY},
8859
+ {" MAX_PPR" , 2 , MYSQL_TYPE_TINY, 0 , 0 , 0 , OPEN_FRM_ONLY},
8860
+ {" SRID" , 5 , MYSQL_TYPE_SHORT, 0 , 0 , 0 , OPEN_FRM_ONLY},
8861
+ {0 , 0 , MYSQL_TYPE_STRING, 0 , 0 , 0 , 0 }
8862
+ };
8863
+
8864
+
8865
+ ST_FIELD_INFO spatial_ref_sys_fields_info[]=
8866
+ {
8867
+ {" SRID" , 5 , MYSQL_TYPE_SHORT, 0 , 0 , 0 , SKIP_OPEN_TABLE},
8868
+ {" AUTH_NAME" , FN_REFLEN, MYSQL_TYPE_STRING, 0 , 0 , 0 , SKIP_OPEN_TABLE},
8869
+ {" AUTH_SRID" , 5 , MYSQL_TYPE_SHORT, 0 , 0 , 0 , SKIP_OPEN_TABLE},
8870
+ {" SRTEXT" , 2048 , MYSQL_TYPE_STRING, 0 , 0 , 0 , SKIP_OPEN_TABLE},
8871
+ {0 , 0 , MYSQL_TYPE_STRING, 0 , 0 , 0 , 0 }
8872
+ };
8873
+ #endif /* HAVE_SPATIAL*/
8874
+
8875
+
8750
8876
/*
8751
8877
Description of ST_FIELD_INFO in table.h
8752
8878
@@ -8847,6 +8973,13 @@ ST_SCHEMA_TABLE schema_tables[]=
8847
8973
{" VIEWS" , view_fields_info, 0 ,
8848
8974
get_all_tables, 0 , get_schema_views_record, 1 , 2 , 0 ,
8849
8975
OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE},
8976
+ #ifdef HAVE_SPATIAL
8977
+ {" GEOMETRY_COLUMNS" , geometry_columns_fields_info, 0 ,
8978
+ get_all_tables, make_columns_old_format, get_geometry_column_record,
8979
+ 1 , 2 , 0 , OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
8980
+ {" SPATIAL_REF_SYS" , spatial_ref_sys_fields_info, 0 ,
8981
+ fill_spatial_ref_sys, make_old_format, 0 , -1 , -1 , 0 , 0 },
8982
+ #endif /* HAVE_SPATIAL*/
8850
8983
{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
8851
8984
};
8852
8985
0 commit comments