Subject: | Support for bind_param(..., { pg_type => PG_INTERVAL }) |
Attached patch allows bind_param() with pg_type=>PG_INTERVAL.
Currently, as reported by Filip RembiaĆkowski, it just croaks
with a "not supported" message:
http://archives.postgresql.org/pgsql-general/2008-05/msg00877.php
The patch is for current SVN trunk, generated by adding the following
line to types.c and running "perl -x types.c /path/to/pg-3.1":
interval quote_string dequote_string SQL_INTERVAL 1 0
Subject: | dbd_pg_interval_trunk.patch |
Index: types.c
===================================================================
--- types.c (revision 11304)
+++ types.c (working copy)
@@ -103,7 +103,7 @@
{PG_INT4 ,"int4" ,',',"int4out" ,null_quote ,null_dequote ,{SQL_INTEGER},1,1},
{PG_INT8 ,"int8" ,',',"int8out" ,null_quote ,null_dequote ,{SQL_BIGINT},1,0},
{PG_INTERNAL ,"internal" ,',',"internal_out" ,quote_string,dequote_string,{0},1,0},
- {PG_INTERVAL ,"interval" ,',',"interval_out" ,quote_string,dequote_string,{0},1,0},
+ {PG_INTERVAL ,"interval" ,',',"interval_out" ,quote_string,dequote_string,{SQL_INTERVAL},1,0},
{PG_LANGUAGE_HANDLER ,"language_handler" ,',',"language_handler_out",quote_string,dequote_string,{0},1,0},
{PG_LINE ,"line" ,',',"line_out" ,quote_geom ,dequote_string,{0},1,0},
{PG_LSEG ,"lseg" ,',',"lseg_out" ,quote_geom ,dequote_string,{0},1,0},
@@ -310,6 +310,7 @@
{SQL_TINYINT,"SQL_TINYINT",',', "none", null_quote, null_dequote, {PG_INT2}, 1, 1},
{SQL_INTEGER,"SQL_INTEGER",',', "none", null_quote, null_dequote, {PG_INT4}, 1, 1},
{SQL_BIGINT,"SQL_BIGINT",',', "none", null_quote, null_dequote, {PG_INT8}, 1, 0},
+ {SQL_INTERVAL,"SQL_INTERVAL",',', "none", quote_string, dequote_string, {PG_INTERVAL}, 1, 0},
{SQL_VARCHAR,"SQL_VARCHAR",',', "none", null_quote, null_dequote, {PG_NAME}, 1, 0},
{SQL_DECIMAL,"SQL_DECIMAL",',', "none", null_quote, null_dequote, {PG_NUMERIC}, 1, 2},
{SQL_LONGVARCHAR,"SQL_LONGVARCHAR",',', "none", quote_string, dequote_string, {PG_TEXT}, 1, 0},
@@ -338,14 +339,15 @@
case SQL_TINYINT: return &sql_types[10];
case SQL_INTEGER: return &sql_types[11];
case SQL_BIGINT: return &sql_types[12];
- case SQL_DECIMAL: return &sql_types[14];
- case SQL_LONGVARCHAR: return &sql_types[15];
- case SQL_TYPE_TIME: return &sql_types[16];
- case SQL_TIMESTAMP: return &sql_types[17];
- case SQL_TYPE_TIMESTAMP: return &sql_types[18];
- case SQL_TYPE_TIMESTAMP_WITH_TIMEZONE: return &sql_types[19];
- case SQL_TYPE_TIME_WITH_TIMEZONE: return &sql_types[20];
- case SQL_VARCHAR: return &sql_types[21];
+ case SQL_INTERVAL: return &sql_types[13];
+ case SQL_DECIMAL: return &sql_types[15];
+ case SQL_LONGVARCHAR: return &sql_types[16];
+ case SQL_TYPE_TIME: return &sql_types[17];
+ case SQL_TIMESTAMP: return &sql_types[18];
+ case SQL_TYPE_TIMESTAMP: return &sql_types[19];
+ case SQL_TYPE_TIMESTAMP_WITH_TIMEZONE: return &sql_types[20];
+ case SQL_TYPE_TIME_WITH_TIMEZONE: return &sql_types[21];
+ case SQL_VARCHAR: return &sql_types[22];
default: return NULL;
}
}
@@ -742,6 +744,7 @@
time quote_string dequote_string SQL_TYPE_TIME 1 0
timestamp quote_string dequote_string SQL_TIMESTAMP|SQL_TYPE_TIMESTAMP 1 0
timestamptz quote_string dequote_string SQL_TYPE_TIMESTAMP_WITH_TIMEZONE|SQL_TYPE_TIME_WITH_TIMEZONE 1 0
+interval quote_string dequote_string SQL_INTERVAL 1 0
__END__