2

Its not supported? I get an exception when trying to insert data with command parameter set as:

var parameter = ((IDbDataParameter)cmd.Parameters[index]);
var list = (string[][])value;
parameter.Value = list;

With message

System.NotSupportedException: This .NET type is not supported in Npgsql or your PostgreSQL: System.String[][]

I'm using PostgreSQL 9.4 and created a column with type text[][]. Since text[] maps to string[] without any issues, I can't see a reason why two dimensional arrays are not working.

Sly
  • 15,046
  • 12
  • 60
  • 89

1 Answers1

2

There is no data type text[][] in Postgres. Syntax variants indicating multiple array dimensions are tolerated for documentation, but internally all of those are mapped to the same (and only) array type that works for any number of dimensions: text[]. Try string[] in your .net declaration.

You don't have to take my word, test yourself:

SELECT pg_typeof(NULL::text[][])            AS type1
     , pg_typeof('{a,b}'::text[][])         AS type2
     , pg_typeof('{{{a,b},{c,d}}, {{a,b},{c,d}}}'::text[][][][][]) AS type3;


 type1  | type2  | type3
--------+--------+--------
 text[] | text[] | text[]

Related:

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
  • there is a schedule field in the documentation that has text[][] type http://www.postgresql.org/docs/current/static/arrays.html ?.. – Sly Dec 16 '15 at 14:59
  • 1
    @Sly: Yes, it documents that the syntax is *allowed*, but the only actual data type is still `text[]`. [Keep reading for a few lines more and it's all there.](http://www.postgresql.org/docs/current/interactive/arrays.html#ARRAYS-DECLARATION) I added a demo above. – Erwin Brandstetter Dec 16 '15 at 15:10