@@ -41,14 +41,54 @@ class IscColumnsResultSet : public IscMetaDataResultSet
4141 IscColumnsResultSet (IscDatabaseMetaData *metaData);
4242 void initResultSet (IscStatement *stmt);
4343private:
44- virtual bool getDefSource (int indexIn, int indexTarget);
4544 virtual void setCharLen (int charLenInd, int fldLenInd, IscSqlType &sqlType);
4645 virtual void checkQuotes (IscSqlType &sqlType, JString stringVal);
4746 virtual void adjustResults (IscSqlType &sqlType);
4847
4948 IscBlob blob;
5049 CAttrArray arrAttr;
5150 IscSqlType sqlType;
51+
52+ static constexpr int COLUMN_DEFAULT_TARGET = 13 ;
53+ static constexpr int COLUMN_DEFAULT_SRC[] = { 26 , 20 };
54+ static constexpr char DEFAULT_SIGNATURE[] = " DEFAULT" ;
55+
56+ inline void setFieldDefault (bool removeQuotes = false )
57+ {
58+ sqlda->updateVarying (COLUMN_DEFAULT_TARGET, " NULL" );
59+
60+ for (auto src_fld : COLUMN_DEFAULT_SRC)
61+ {
62+ if (!sqlda->isNull (src_fld))
63+ {
64+ auto * var = sqlda->Var (src_fld);
65+ char buffer[1024 ];
66+ int lenRead;
67+
68+ blob.directOpenBlob ((char *)var->sqldata );
69+ blob.directFetchBlob (buffer, sizeof (buffer) - 1 , lenRead);
70+ blob.directCloseBlob ();
71+
72+ const char * first = buffer + (strncasecmp (buffer, DEFAULT_SIGNATURE, lenRead) ? 0 : sizeof (DEFAULT_SIGNATURE) - 1 );
73+ char * last = buffer + lenRead - 1 ;
74+
75+ while (*first == ' ' ) ++first;
76+ while (last > first && *last == ' ' ) --last;
77+
78+ if (removeQuotes && *first == ' \' ' && last > first)
79+ {
80+ ++first;
81+ if (*last == ' \' ' )
82+ --last;
83+ }
84+
85+ *(last + 1 ) = ' \0 ' ;
86+
87+ sqlda->updateVarying (COLUMN_DEFAULT_TARGET, first);
88+ break ;
89+ }
90+ }
91+ }
5292};
5393
5494}; // end namespace IscDbcLibrary
0 commit comments