@@ -1094,7 +1094,29 @@ LIBPQ_CC_connect(ConnectionClass *self, char *salt_para)
10941094
10951095 if (ret = LIBPQ_connect (self ), ret <= 0 )
10961096 return ret ;
1097- res = CC_send_query (self , "SET DateStyle = 'ISO';SET extra_float_digits = 2;" ISOLATION_SHOW_QUERY , NULL , READ_ONLY_QUERY , NULL );
1097+
1098+ /* Check current DateStyle first */
1099+ res = CC_send_query (self , "SHOW DateStyle;" , NULL , READ_ONLY_QUERY , NULL );
1100+ if (QR_command_maybe_successful (res ))
1101+ {
1102+
1103+ if (res -> command && (stricmp (res -> command , "SHOW" ) == 0 )
1104+ && (strcmp (QR_get_fieldname (res , 0 ), "DateStyle" ) == 0 )){
1105+ const char * datestyle = QR_get_value_backend_text (res , 0 , 0 );
1106+ /* Only set DateStyle if it's not already ISO */
1107+ if (datestyle && (strncmp (datestyle , "ISO" , 3 ) != 0 ))
1108+ {
1109+ QR_Destructor (res );
1110+ res = CC_send_query (self , "SET DateStyle = 'ISO';" ISOLATION_SHOW_QUERY , NULL , READ_ONLY_QUERY , NULL );
1111+ }
1112+ else
1113+ {
1114+ QR_Destructor (res );
1115+ res = CC_send_query (self , ISOLATION_SHOW_QUERY , NULL , READ_ONLY_QUERY , NULL );
1116+ }
1117+ }
1118+ }
1119+
10981120 if (QR_command_maybe_successful (res ))
10991121 {
11001122 handle_show_results (res );
0 commit comments