Title: Failed once again to import shapefile to PostGIS DB using ogr2ogr
Tags: postgis;shapefile;ogr2ogr
Question: Once again I try to import a shapefile to my remote PostGIS database using og2ogr. Last time it was an Odyssey but I have managed to solve all the issues and report them one by one here. 

I have checked everything:


Permissions of files, 
Path of shapefiles, 
Validity of shapefile, 
triple checked my ogr2ogr command, 
used ogrinfo to validate my connection to the DB and check the shapefile, 
granted roles on my user and on the required tables (e.g. spatial_ref_sys)
if the table already exists
etc.


This is my ogr2ogr command:

```ogr2ogr -f "PostgreSQL" PG:"host=localhost user=my_user password=my_pass dbname=my_db_name" -nlt GEOMETRY my_shape_file.shp
```

And the error I get (also checked the PostgreSQL log files) is:

```ERROR 1: AddGeometryColumn failed for layer wld_bnd_adm2_gaul_2015, layer creation has failed.
ERROR 1: Terminating translation prematurely after failed
translation of layer wld_bnd_adm2_gaul_2015 (use -skipfailures to skip errors)
```

Last time I got this error cause I haven't GRANTED permissions to my user. That have solved the problem:

```GRANT ALL ON TABLE spatial_ref_sys TO my_user_name;
```

But not this time.

And that's what I see on my log file:

```ERROR:  function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) is not unique at character 8
HINT:  Could not choose a best candidate function. You might need to add explicit type casts.
STATEMENT:  SELECT AddGeometryColumn('public','wld_bnd_adm2_gaul_2015','wkb_geometry',4326,'GEOMETRY',2)
```

Comment: If you need a quick solution, you could try to load it via the QGIS DB Manager plugin...

Comment: Are you certain that your postgres database has the postgis extension loaded? Also, if you use pgAdmin, you could try using the PostGIS Shapefile and DBF loader that comes with that software

Comment: Tried with shp2pgsql plugin. It didnt work either.

Comment: Can you upload your shapefile somewhere so I can give it a go?

Comment: `-nlt GEOMETRY` I don't think GEOMETRY is a valid parameter here. I think you need to pass in the geometry type, like POLYGON, LINESTRING, etc.

Comment: -nlt should work. I think its a matter of the database rather than the shapefile. I tried also with other shapefiles and got the same issue.

Comment: -nlt geometry is ok. There may be some old stuff in the database. I would try with -overwrite or with -nln name_i_have_not_used_before.

Here is the accepted answer: I figured this out.
It seems like there were some artifact functions with the name addGeometryColumn (overloading in postgres is possible).

This error in the logfile made me suspect there is something very wrong with the addGeometryColumn function:

```ERROR:  function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) is not unique at character 8
```

After droping the functions (DROP FUNCTION ..) the issue was resolved!

Comment for this answer: Interesting. So you dropped an overloaded function for which you had duplicate names, but different argument signatures? ..I'm curious as to how they got there in the first place! :)


{'source': 'StackExchangeDataset', 'subset': 'gis.stackexchange.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:06/16/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<postgis><shapefile><ogr2ogr>', 'Title': 'Failed once again to import shapefile to PostGIS DB using ogr2ogr', 'ViewCount': 628, 'id': 198733, 'user_AboutMe': None, 'user_AccountId': 1895473.0, 'user_DisplayName': 'user1919', 'user_Reputation': 2534.0, 'user_Views': 154.0, 'user_id': 40618.0}}