@@ -237,7 +237,7 @@ CC_conninfo_init(ConnInfo *conninfo)
237237{
238238memset (conninfo ,0 ,sizeof (ConnInfo ));
239239conninfo -> disallow_premature = -1 ;
240- conninfo -> updatable_cursors = -1 ;
240+ conninfo -> allow_keyset = -1 ;
241241conninfo -> lf_conversion = -1 ;
242242conninfo -> true_is_minus1 = -1 ;
243243memcpy (& (conninfo -> drivers ),& globals ,sizeof (globals ));
@@ -293,6 +293,7 @@ CC_Constructor()
293293rv -> unicode = 0 ;
294294rv -> result_uncommitted = 0 ;
295295rv -> schema_support = 0 ;
296+ rv -> isolation = SQL_TXN_READ_COMMITTED ;
296297#ifdef MULTIBYTE
297298rv -> client_encoding = NULL ;
298299rv -> server_encoding = NULL ;
@@ -996,6 +997,12 @@ CC_connect(ConnectionClass *self, char do_password)
996997}
997998#endif /* UNICODE_SUPPORT */
998999#endif /* MULTIBYTE */
1000+ ci -> updatable_cursors = 0 ;
1001+ #ifdef DRIVER_CURSOR_IMPLEMENT
1002+ if (!ci -> drivers .use_declarefetch &&
1003+ PG_VERSION_GE (self ,7.0 ))/* Tid scan since 7.0 */
1004+ ci -> updatable_cursors = ci -> allow_keyset ;
1005+ #endif /* DRIVER_CURSOR_IMPLEMENT */
9991006
10001007CC_clear_error (self );/* clear any initial command errors */
10011008self -> status = CONN_CONNECTED ;
@@ -1130,17 +1137,19 @@ voidCC_on_commit(ConnectionClass *conn)
11301137}
11311138conn -> result_uncommitted = 0 ;
11321139}
1133- void CC_on_abort (ConnectionClass * conn ,BOOL set_no_trans )
1140+ void CC_on_abort (ConnectionClass * conn ,UDWORD opt )
11341141{
11351142if (CC_is_in_trans (conn ))
11361143{
11371144#ifdef DRIVER_CURSOR_IMPLEMENT
11381145if (conn -> result_uncommitted )
11391146ProcessRollback (conn , TRUE);
11401147#endif /* DRIVER_CURSOR_IMPLEMENT */
1141- if (set_no_trans )
1148+ if (0 != ( opt & NO_TRANS ) )
11421149CC_set_no_trans (conn );
11431150}
1151+ if (0 != (opt & CONN_DEAD ))
1152+ conn -> status = CONN_DOWN ;
11441153conn -> result_uncommitted = 0 ;
11451154}
11461155
@@ -1162,8 +1171,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
11621171BOOL clear_result_on_abort = ((flag & CLEAR_RESULT_ON_ABORT )!= 0 ),
11631172create_keyset = ((flag & CREATE_KEYSET )!= 0 ),
11641173issue_begin = ((flag & GO_INTO_TRANSACTION )!= 0 && !CC_is_in_trans (self ));
1165- char swallow ,
1166- * wq ;
1174+ char swallow ,* wq ,* ptr ;
11671175int id ;
11681176SocketClass * sock = self -> sock ;
11691177int maxlen ,
@@ -1173,8 +1181,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
11731181query_completed = FALSE,
11741182before_64 = PG_VERSION_LT (self ,6.4 ),
11751183aborted = FALSE,
1176- used_passed_result_object = FALSE,
1177- set_no_trans ;
1184+ used_passed_result_object = FALSE;
1185+ UDWORD abort_opt ;
11781186
11791187/* ERROR_MSG_LENGTH is suffcient */
11801188static char msgbuffer [ERROR_MSG_LENGTH + 1 ];
@@ -1201,7 +1209,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12011209{
12021210self -> errornumber = CONNECTION_COULD_NOT_SEND ;
12031211self -> errormsg = "Could not send Query to backend" ;
1204- CC_on_abort (self ,TRUE );
1212+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
12051213return NULL ;
12061214}
12071215
@@ -1210,7 +1218,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12101218{
12111219self -> errornumber = CONNECTION_COULD_NOT_SEND ;
12121220self -> errormsg = "Could not send Query to backend" ;
1213- CC_on_abort (self ,TRUE );
1221+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
12141222return NULL ;
12151223}
12161224
@@ -1223,7 +1231,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12231231{
12241232self -> errornumber = CONNECTION_COULD_NOT_SEND ;
12251233self -> errormsg = "Could not send Query to backend" ;
1226- CC_on_abort (self ,TRUE );
1234+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
12271235return NULL ;
12281236}
12291237
@@ -1260,7 +1268,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12601268self -> errormsg = "No response from the backend" ;
12611269
12621270mylog ("send_query: 'id' - %s\n" ,self -> errormsg );
1263- CC_on_abort (self ,TRUE );
1271+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
12641272ReadyToReturn = TRUE;
12651273retres = NULL ;
12661274break ;
@@ -1284,7 +1292,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12841292self -> errornumber = CONNECTION_NO_RESPONSE ;
12851293self -> errormsg = "No response from backend while receiving a portal query command" ;
12861294mylog ("send_query: 'C' - %s\n" ,self -> errormsg );
1287- CC_on_abort (self ,TRUE );
1295+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
12881296ReadyToReturn = TRUE;
12891297retres = NULL ;
12901298}
@@ -1312,11 +1320,20 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
13121320else if (strnicmp (cmdbuffer ,"COMMIT" ,6 )== 0 )
13131321CC_on_commit (self );
13141322else if (strnicmp (cmdbuffer ,"ROLLBACK" ,8 )== 0 )
1315- CC_on_abort (self ,TRUE );
1323+ CC_on_abort (self ,NO_TRANS );
13161324else if (strnicmp (cmdbuffer ,"END" ,3 )== 0 )
13171325CC_on_commit (self );
13181326else if (strnicmp (cmdbuffer ,"ABORT" ,5 )== 0 )
1319- CC_on_abort (self , TRUE);
1327+ CC_on_abort (self ,NO_TRANS );
1328+ else
1329+ {
1330+ trim (cmdbuffer );/* get rid of trailing space */
1331+ ptr = strrchr (cmdbuffer ,' ' );
1332+ if (ptr )
1333+ res -> recent_processed_row_count = atoi (ptr + 1 );
1334+ else
1335+ res -> recent_processed_row_count = -1 ;
1336+ }
13201337
13211338if (QR_command_successful (res ))
13221339QR_set_status (res ,PGRES_COMMAND_OK );
@@ -1400,15 +1417,15 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
14001417qlog ("ERROR from backend during send_query: '%s'\n" ,msgbuffer );
14011418
14021419/* We should report that an error occured. Zoltan */
1403- set_no_trans = FALSE ;
1420+ abort_opt = 0 ;
14041421if (!strncmp (msgbuffer ,"FATAL" ,5 ))
14051422{
14061423self -> errornumber = CONNECTION_SERVER_REPORTED_ERROR ;
1407- set_no_trans = TRUE ;
1424+ abort_opt = NO_TRANS | CONN_DEAD ;
14081425}
14091426else
14101427self -> errornumber = CONNECTION_SERVER_REPORTED_WARNING ;
1411- CC_on_abort (self ,set_no_trans );
1428+ CC_on_abort (self ,abort_opt );
14121429QR_set_status (res ,PGRES_FATAL_ERROR );
14131430QR_set_message (res ,msgbuffer );
14141431QR_set_aborted (res , TRUE);
@@ -1497,7 +1514,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
14971514default :
14981515self -> errornumber = CONNECTION_BACKEND_CRAZY ;
14991516self -> errormsg = "Unexpected protocol character from backend (send_query)" ;
1500- CC_on_abort (self ,TRUE );
1517+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
15011518
15021519mylog ("send_query: error - %s\n" ,self -> errormsg );
15031520ReadyToReturn = TRUE;
@@ -1585,7 +1602,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
15851602{
15861603self -> errornumber = CONNECTION_COULD_NOT_SEND ;
15871604self -> errormsg = "Could not send function to backend" ;
1588- CC_on_abort (self ,TRUE );
1605+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
15891606return FALSE;
15901607}
15911608
@@ -1594,7 +1611,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
15941611{
15951612self -> errornumber = CONNECTION_COULD_NOT_SEND ;
15961613self -> errormsg = "Could not send function to backend" ;
1597- CC_on_abort (self ,TRUE );
1614+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
15981615return FALSE;
15991616}
16001617
@@ -1643,7 +1660,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16431660case 'E' :
16441661SOCK_get_string (sock ,msgbuffer ,ERROR_MSG_LENGTH );
16451662self -> errormsg = msgbuffer ;
1646- CC_on_abort (self ,FALSE );
1663+ CC_on_abort (self ,0 );
16471664
16481665mylog ("send_function(V): 'E' - %s\n" ,self -> errormsg );
16491666qlog ("ERROR from backend during send_function: '%s'\n" ,self -> errormsg );
@@ -1656,7 +1673,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16561673default :
16571674self -> errornumber = CONNECTION_BACKEND_CRAZY ;
16581675self -> errormsg = "Unexpected protocol character from backend (send_function, args)" ;
1659- CC_on_abort (self ,TRUE );
1676+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
16601677
16611678mylog ("send_function: error - %s\n" ,self -> errormsg );
16621679return FALSE;
@@ -1690,7 +1707,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16901707case 'E' :
16911708SOCK_get_string (sock ,msgbuffer ,ERROR_MSG_LENGTH );
16921709self -> errormsg = msgbuffer ;
1693- CC_on_abort (self ,FALSE );
1710+ CC_on_abort (self ,0 );
16941711mylog ("send_function(G): 'E' - %s\n" ,self -> errormsg );
16951712qlog ("ERROR from backend during send_function: '%s'\n" ,self -> errormsg );
16961713
@@ -1711,7 +1728,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
17111728default :
17121729self -> errornumber = CONNECTION_BACKEND_CRAZY ;
17131730self -> errormsg = "Unexpected protocol character from backend (send_function, result)" ;
1714- CC_on_abort (self ,TRUE );
1731+ CC_on_abort (self ,NO_TRANS | CONN_DEAD );
17151732
17161733mylog ("send_function: error - %s\n" ,self -> errormsg );
17171734return FALSE;